Re: System headers, compiler conformance...



s0suk3@xxxxxxxxx writes:
On Aug 8, 3:20=A0pm, viza <tom.viza@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
On Fri, 08 Aug 2008 12:08:45 -0700, s0suk3 wrote:
I have a C source file that includes several system header files (namel=
y
<sys/types.h>, <sys/socket.h>, <unistd.h> and <netdb.h>).
When I compile it by invoking the compiler in conforming mode, it
doesn't object to the inclusion of the headers, but it gives me errors
for every function, type, etc, that I use
when I compile it in non-conforming mode, it's All Good.

Try using gcc -E to inspect the output of the pre-processor.

$ cat foo.c
#include <header.h>

$ gcc -E foo.c -o foo.cpp
$ cat foo.cpp
/* header.h header file */

int foo(int);

$

See if the headers are there.

It might be that they are included conditionally:

#ifdef SOMETHING

int foo(int);

#endif

in which case then the macro SOMETHING might not be defined in standard
mode.

You're right. Thanks. One macro that's conditioning-out something that
I need (the 'addrinfo' struct, and the getnameinfo() and
freeaddrinfo() funcs) is '__USE_POSIX', in the <netdb.h> header. So I
could define this macro in my source, but I think there are other
things that are being conditioned-out, and going through all those
header files seems cumbersome, plus that doesn't seem like a good
solution anyway.

The gcc flag I'm using is std=3Dc99. The code I have uses C99 features
that will be disabled if I don't use that flag. What do you suggest I
should do?


1) don't use the c99 features in question.

2) from the gcc man page

Even when this option is not specified, you can still use some of
the features of newer standards in so far as they do not conflict
with previous C standards. For example, you may use "__restrict__"
even when -std=c99 is not specified.
.



Relevant Pages

  • Re: Solaris gcc structure alignment
    ... > I'm trying to compile some code on solaris 10 using gcc 3.4.2. ... > The reason why I use 1-byte alignment is because it's used for headers to ... Map a structure pointer to it's header and see if magic, ... Does anyone know if it's possible to compile object files with gcc ...
    (comp.unix.programmer)
  • Solaris gcc structure alignment
    ... I'm trying to compile some code on solaris 10 using gcc 3.4.2. ... The reason why I use 1-byte alignment is because it's used for headers to ... Map a structure pointer to it's header and see if magic, ...
    (comp.unix.programmer)
  • Re: Solaris gcc structure alignment
    ... >I'm trying to compile some code on solaris 10 using gcc 3.4.2. ... >This code has some 1-byte aligned structures. ... Are the headers even the right endianess? ... Does anyone know if it's possible to compile object files with gcc ...
    (comp.unix.programmer)
  • Re: Linux Compiler Problem
    ... It seems the gcc on your machine cannot find standard c headers ... The file I'm trying to compile can be found here: ... with regular user privileges and super user privileges. ...
    (comp.soft-sys.matlab)
  • Re: Recommended version of gcc for Python?
    ... Most versions of gcc should be just fine to compile Python. ... but does not yet use any C99 features. ...
    (comp.lang.python)

Loading