Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

0 views
Skip to first unread message

Kok How Teh

unread,
Apr 10, 2010, 9:48:41 AM4/10/10
to
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.

Alexander Bartolich

unread,
Apr 10, 2010, 10:05:12 AM4/10/10
to
Kok How Teh wrote:
> [...]

> 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.

http://c-faq.com/struct/structhack.html

--

Eric Sosman

unread,
Apr 10, 2010, 10:12:45 AM4/10/10
to

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.

--
Eric Sosman
eso...@ieee-dot-org.invalid

Seebs

unread,
Apr 10, 2010, 1:28:32 PM4/10/10
to

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

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!

0 new messages