intel driver will only compile with gcc

Daniel Stone daniel at fooishbar.org
Tue Jun 12 13:46:48 PDT 2007


On Tue, Jun 12, 2007 at 02:39:11PM -0600, Brian Paul wrote:
> Daniel Stone wrote:
> > On Tue, Jun 12, 2007 at 10:17:57AM -0700, Kean Johnston wrote:
> >> That code works only with a C99 compiler.
> > 
> > No, again, it does not require a C99 compiler.  gcc is not a C99
> > compiler.
> 
> By default, gcc is rather loose in terms of C standards adherence.
> 
> If you add -pedantic to your flags you'll see that named initializers 
> generate warnings with gcc (since the default standard is -std=gnu89).
> 
> Example:
> $ gcc -pedantic -c init.c
> init.c:12: warning: ISO C90 forbids specifying subobject to initialize
> init.c:13: warning: ISO C90 forbids specifying subobject to initialize
> 
> If -pedantic (or -ansi) were used when building X, we'd certainly see 
> some new warnings.  If your code uses named initializers and you really 
> care about following the C spec, you'd have to run gcc with -std=c99 
> because they're not a feature of c89.
> 
> Kean's point is valid.

Indeed, I'm aware of -ansi -pedantic, et al, but the point is that you
don't have to have a full C99-compliant compiler to get named
initialisers.  You can pick and choose your extended features.

> >> The named initializer buys you absolutely nothing whatsoever.
> > 
> > Bar the legibility.
> 
> Named initializers do indeed have value beyond legibility.  Suppose you 
> have a struct:
> 
> struct foo { int x, y; };
> 
> and initialize a variable f with:
> 
> struct foo f = { 1, 2 };
> 
> Now suppose someone interchanged the order of x and y in foo and wasn't 
> aware of f's initialization.  The variable f will be initialized 
> differently.

Well, that would be an ABI break, anyway.  They also have a great deal
of value in partial initialisation.  The SI doesn't exactly have the
smallest structures around, so having:
foo = {
    .name = "bar",
    .other = thing,
    .thing = meh,
};

will definitely beat:
foo = { NULL, NULL, 0, 0, NULL, 0, NULL, 0, 0, "bar", 0, 0, 0, 0, 0,
NULL, NULL, NULL, NULL, NULL, NULL, thing, NULL, 0, 0, NULL, meh, NULL,
NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0, NULL, NULL };

Bearing in mind also that the former is more portable towards adding
struct members than the latter.

Cheers,
Daniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.x.org/archives/xorg/attachments/20070612/d44b2b1a/attachment.pgp>


More information about the xorg mailing list