views:

112

answers:

1

Here's a simple C file:

#include <stdio.h>
#include <stdlib.h>

int
main() {
    printf("hi there!\n");
    return 0;
}

Compiling with gcc -ansi -pedantic -pedantic-errors gives this:

In file included from /usr/include/i386/_structs.h:38,
             from /usr/include/machine/_structs.h:31,
             from /usr/include/sys/_structs.h:57,
             from /usr/include/sys/signal.h:154,
             from /usr/include/sys/wait.h:116,
             from /usr/include/stdlib.h:65,
             from test.c:2:
/usr/include/mach/i386/_structs.h:91: error: type of bit-field ‘__invalid’ is a GCC extension

With lots more errors about GCC extensions. I know that I could just remove the -pedantic-errors switch and recompile, but for one reason and another, that isn't in the cards. Is there a way to get past this error; perhaps downloading & installing another C library? I'm working locally on code that needs to compile on a remote machine, so I can't set up the Makefile to point at a special library location, unfortunately.

+1  A: 

You could possibly modify /usr/include/mach/i386/_structs.h:91 to use the __extension__ keyword. Although you'd have to wonder why this is not already the case.

Another file level solution is to add a #pragma GCC system_header directive to the top of _structs.h.

To fix it at the build level, add -isystem /usr/include/mach/i386/ to the compiler options. All headers in that folder will then be included as if they were system headers (which should be the case already but apparently is not).

Clifford
I do wonder, I do. It's not like stdlib.h is some weird mach-only header file, for cryin out loud. I'm sure your solution would work, but it's definitely a last-ditch solution, I think.
slide_rule
OK, I've added a couple of additional solutions, one of which is applied to the build rather than the file.
Clifford