Skip to contentSkip to conversation

udev compile problem: udevd

DISCUSSION Thomas Strösslin 3 participants 4 messages Dec 20, 2004 – Dec 21, 2004

lore
Share & tools
lore
#0 lore raw

Hi,

I failed to compile udev-050.
in udevd.h, the structure hotplug_msg{} contains:

	char envbuf[];

This does not compile on my system (SuSE 7.3, gcc 2.95.3)

It does compile if you replace "envbuf[]" with "*envbuf"

cheers,
tom

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#1 lore raw
Quoted 10 lines · Thomas Strösslin

Hi,

I failed to compile udev-050.
in udevd.h, the structure hotplug_msg{} contains:

	char envbuf[];

This does not compile on my system (SuSE 7.3, gcc 2.95.3)

It does compile if you replace "envbuf[]" with "*envbuf"

A variable sized array is not a pointer! You will get a different sizeof(), which may cause problems.

Kay

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#2 lore raw
In reply to Thomas Strösslin
Quoted 2 lines · Kay Sievers

A variable sized array is not a pointer! You will get a different sizeof(), which may cause problems.

Beware that gcc does not conform to C99 in regards to the size of a structure containing a flexible array. For example:

struct foo{ int i; char c; char arr[]; };

gcc-3.4.2/i386 reports sizeof(struct foo) as 8 and offsetof(struct foo,arr) as 5; but C99 requires those values to be the same. More here:

http://gcc.gnu.org/gcc-3.4/c99status.html
http://gcc.gnu.org/ml/gcc/2002-05/msg02844.html

-Dave Dodge

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#3 lore raw
In reply to Thomas Strösslin
Quoted 7 lines · Dave Dodge
Quoted 2 lines · Kay Sievers

A variable sized array is not a pointer! You will get a different sizeof(), which may cause problems.

Beware that gcc does not conform to C99 in regards to the size of a structure containing a flexible array. For example:

Quoted 7 lines

struct foo{ int i; char c; char arr[]; };

gcc-3.4.2/i386 reports sizeof(struct foo) as 8 and offsetof(struct foo,arr) as 5; but C99 requires those values to be the same. More here:

http://gcc.gnu.org/gcc-3.4/c99status.html
http://gcc.gnu.org/ml/gcc/2002-05/msg02844.html

Interesting. Thanks for pointing this out.

Kay

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel