Source:

#include <stdio.h>

struct camproc_string {
 int index;
 char *name;
};

struct camproc_string vga_effect_wb[] = {
    {
        .index  = 0,
        .name = "WB Auto",
    },
    {
        .index  = 1,
        .name   = "WB Sunny",
    },
    {
        .index  = 2,
        .name   = "WB Cloudy",
    },
    {
        .index  = 3,
        .name   = "WB Incandescent",
    },
    {
        .index  = 4,
        .name   = "WB Fluorescent",
    },
};

struct camproc_effect_named {
 int index;
 struct camproc_string *items;
};

static struct camproc_effect_named vga_effect_named[] = {
    {
        .index  = 0,
        .items = *vga_effect_wb,
    },
};

int main(int argc, char *argv[])
{
 printf("%s\n", vga_effect_named[0].items->name);
 
 return 0;
}


Compile:

[jmlim@hera jmlim]$ gcc -o kdsoo kdsoo.c
kdsoo.c:39: initializer element is not constant
kdsoo.c:39: (near initialization for `vga_effect_named[0].items')
kdsoo.c:41: initializer element is not constant
kdsoo.c:41: (near initialization for `vga_effect_named[0]')
[jmlim@hera jmlim]$


Analysis:
단순 포인터 오류.

Solution:
.items = *vga_effect_wb,를 .items = vga_effect_wb로 수정한다.

Compile & Run:

[jmlim@hera jmlim]$ gcc -o kdsoo kdsoo.c
[jmlim@hera jmlim]$ ./kdsoo
WB Auto
[jmlim@hera jmlim]$
Posted by 알 수 없는 사용자
,