구조체 배열 선언시 대괄호 안에 숫자는 뭔가요?

nekoko의 이미지

드라이버 소스를 보다보니 다음같은 구조체 배열 선언이 있던데
중괄호 안 처음에 [0] = { } 이런게 있는데요
이건 뭔가요?

struct sample array[] = {
    <span>[0]</span> = {
        .a = 0, 
        .b = 2,
    },
    <span>[2]</span> = {
        .a = 5,
        .b = 3,
    },
...
};

winner의 이미지

C99 기술인데 이런게 적용되고 있었군요. VC++는... 에휴~

nekoko의 이미지

검색해도 잘 못 찾겠던데..
c99 스펙같은걸 찾아봐야 할까요

"I'm convinced that the only thing that kept me going was that I loved what I did." - Steve Jobs 1955-2011

ymir의 이미지

http://sunsite.ualberta.ca/Documentation/Gnu/gcc-3.0.2/html_mono/gcc.html#SEC89

5.22 Designated Initializers 섹션 살펴보세요.

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

nekoko의 이미지

잘 봤습니다~ 감사해요

"I'm convinced that the only thing that kept me going was that I loved what I did." - Steve Jobs 1955-2011