What's the usage of char buf[0] as a structure element?

K

Kok How Teh

Hi;
I see many "char buf[0];" structure element used in linux kernel
especially in include/net/*.h Could anyone explain what's the use of
this "zero-element" array as an element in a structure? Thanks.

Regards.
 
E

Eric Sosman

Hi;
I see many "char buf[0];" structure element used in linux kernel
especially in include/net/*.h Could anyone explain what's the use of
this "zero-element" array as an element in a structure? Thanks.

This is Question 2.6 in the comp.lang.c Frequently Asked
Questions (FAQ) at <http://www.c-faq.com/>. Your other thread
"dynamic buffer allocation at char buf[1]" is a variation on
the same question.
 
S

Seebs

Hi;
I see many "char buf[0];" structure element used in linux kernel
especially in include/net/*.h Could anyone explain what's the use of
this "zero-element" array as an element in a structure? Thanks.

It's a pre-C99 version of a flexible array member.

-s
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top