Orphaning GCL

Bryn M. Reeves bmr at redhat.com
Wed Nov 5 14:05:35 UTC 2008


Jerry James wrote:
> On Wed, Nov 5, 2008 at 6:32 AM, Richard W.M. Jones <rjones at redhat.com> wrote:
>> On Mon, Nov 03, 2008 at 08:45:29PM -0700, Jerry James wrote:
>>> int main() {
>>> #include <unistd.h>
>>>   return 0;
>>> }
>> Is it supposed to be possible to compile this?
> 
> No, that's not legal C.  I didn't know that, so I learned something
> from the experience, which makes it a good one.  I sent a patch
> upstream yesterday to fix the GCL code so it doesn't do this.

OT but.. That snippet *is* legal C, but the validity of compiling this 
file then depends on the content of unistd.h (which if it's a "real" 
unistd.h will of course never produce legal preprocessed C...).

If the file being included were to just contain e.g. statements, macro 
or variable declarations and definitions the above code would compile 
just fine.

You can put a preprocessor directive pretty much anywhere you like, as 
long as it's the first non-whitespace thing on the line (I think), 
you're just expected to make sure the results of processing that 
directive result in legal preprocessed sources.

Regards,
Bryn.

---x.c---
#include <stdio.h>
int main(int argc, char **argv)
{
#include "y.h"
         return 0;
}

---y.h---
int a = 2, b = 2;
printf("%d + %d = %d\n", a, b, a+b);




More information about the fedora-devel-list mailing list