lkml.org 
[lkml]   [1999]   [Sep]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Some general LINUX questions on compiling and header files
> > 1. Is there a standard preprocessor token you can check for to know that the
> > compilation is on Linux? I'm looking for something like the __sun token that
> > is predefined by the compiler, so I can put conditional code in a module I
> > share amoungst multiple operating systems.
>
> take a look at your /usr/lib/gcc-lib/*/*/specs file. the important line is:
> specs:-D__ELF__ -Dunix -Di386 -D__i386__ -Dlinux -Asystem(posix)
>
> so, yes, '#ifdef linux' will work (assuming everyone's specs file is like
> mine, hee hee)

Actually the *predefines line is special. The driver program will go through
and any -D<name> options will also do -D__<name>__ and -D__<name>. The ISO C
rules require that no name in the user's namespace be defined at the time of
compilation, so if you use -ansi, the -D<name> is not passed to the
preprocessor. Thus it is never a good idea to use:

#ifdef linux

You should instead use:

#ifdef __linux__

> > 2. Where is the <stddef.h> header file required by ANSI C? I looked in
> > /usr/include and didn't see it.

GCC provides stddef.h. Look in:

/usr/lib/gcc-lib/*/*/include/

--
Michael Meissner, Cygnus Solutions
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886
email: meissner@cygnus.com phone: 978-486-9304 fax: 978-692-4482

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:53    [W:0.032 / U:0.520 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site