Does anyone know of an ifdef which can be used to determine if
a program is being compiled for Solaris?
Thanks
Thanks
+ Does anyone know of an ifdef which can be used to determine if
+ a program is being compiled for Solaris?
Well, I don't use Solaris myself, but take a look at the first
part of the output from a quick "gcc -v":
/usr/local/lib/gnu/lib/gcc-lib/alpha-dec-osf3.0/2.7.1/cpp
-lang-c -v -undef -D__GNUC__=2 -D__GNUC_MINOR__=7 -Dunix
-D__osf__ -D__alpha -D__alpha__ -D_LONGLONG -DSYSTYPE_BSD
-D_SYSTYPE_BSD -D__unix__ -D__osf__ -D__alpha -D__alpha__
-D_LONGLONG -D__SYSTYPE_BSD__ -D_SYSTYPE_BSD -D__unix
-D__SYSTYPE_BSD -Asystem(unix) -Asystem(xpg4) -Acpu(alpha)
-Amachine(alpha) -D__LANGUAGE_C__ -D__LANGUAGE_C -DLANGUAGE_C
foo.c /tmp/ccaapiEa.i
If you have the GNU compiler, take a look at the symbols it
predefines. The command line I used to produce the above just
now was "gcc -v foo.c -o foo" -- no special -D(efines) or
anything -- and I can right away test for the hardware, the OS,
even that fact that it's a *nix and not some PC or a VMS
platform.
Luck++;
Phil
--
#include<std/disclaimer.h> The gods do not protect fools. Fools
> + Does anyone know of an ifdef which can be used to determine if
> + a program is being compiled for Solaris?
> Well, I don't use Solaris myself, but take a look at the first
> part of the output from a quick "gcc -v":
> /usr/local/lib/gnu/lib/gcc-lib/alpha-dec-osf3.0/2.7.1/cpp
> -lang-c -v -undef -D__GNUC__=2 -D__GNUC_MINOR__=7 -Dunix
> -D__osf__ -D__alpha -D__alpha__ -D_LONGLONG -DSYSTYPE_BSD
> -D_SYSTYPE_BSD -D__unix__ -D__osf__ -D__alpha -D__alpha__
> -D_LONGLONG -D__SYSTYPE_BSD__ -D_SYSTYPE_BSD -D__unix
> -D__SYSTYPE_BSD -Asystem(unix) -Asystem(xpg4) -Acpu(alpha)
> -Amachine(alpha) -D__LANGUAGE_C__ -D__LANGUAGE_C -DLANGUAGE_C
> foo.c /tmp/ccaapiEa.i
> If you have the GNU compiler, take a look at the symbols it
> predefines. The command line I used to produce the above just
> now was "gcc -v foo.c -o foo" -- no special -D(efines) or
> anything -- and I can right away test for the hardware, the OS,
> even that fact that it's a *nix and not some PC or a VMS
> platform.
touch does-not-exit.c; gcc -E -dM does-not-exist.c ; rm does-not-exist.c
On my Solaris machine this produces the following:
#define __GCC_NEW_VARARGS__ 1
#define __sparc 1
#define __svr4__ 1
#define __GNUC_MINOR__ 6
#define __sun 1
#define sparc 1
#define __sun__ 1
#define __unix 1
#define __unix__ 1
#define sun 1
#define __GNUC__ 2
#define __sparc__ 1
#define unix 1
cheers
andrew
----------------------------------------------------------
Christmas has been cancelled -- Joseph has confessed all.
-------------------------------------------------------------------------
Now I need the answer to a (perhaps) much tougher question:
How can it be done using the Solaris compiler (Sparkworks)?
Use GNU autoconf and #defines based on actual feature tests
rather than operating system vendor versions.
This is much easier in the long run. You'll look like a
cool programmer too.
Bob
: Much thanks for all the info about gcc.
: Now I need the answer to a (perhaps) much tougher question:
: How can it be done using the Solaris compiler (Sparkworks)?
#include <sys/sockio.h>
#if defined _SC_STREAM_MAX
#define sun5
#else
#define sun4
#endif
--
Fergus Clancy.
In general, #ifdef'ing for a partcular OS is wrong.Quote:>Does anyone know of an ifdef which can be used to determine if
>a program is being compiled for Solaris?
(E.g., if you ifdef' for Solaris 2.x you can't make the distinction
between 2.4 not having bcopy in libc.so and 2.5 having bcopy in
libc.so.)
But both gcc (2.7.0+) and Sun's C compiler (3.0+) now support -D__SVR4.
Casper
Quote:>Does anyone know of an ifdef which can be used to determine if
>a program is being compiled for Solaris?
Oh good! Here's what I had to do to cover SunPro cc and gcc prior toQuote:>But both gcc (2.7.0+) and Sun's C compiler (3.0+) now support -D__SVR4.
#ifdef(sun)
#if defined (__SVR4) || defined (__svr4__)
#define SOLARIS
#endif
#endif
--
Internet Guy/Webmaster 1001 Murphy Ranch Rd. 37 A0 46 EE BE
408-324-6576 Voice and FAX Milpitas CA 95035-7912 95 DB 92 E8 39
I am not a pay TV service! http://www.egbok.com/hbo.html 80 89 A9 F9 3D
FB
Unfortunely, there's no single pre-defined symbol to recognize
Solaris over SunOS, but you can do it with two symbols:
To identify Solaris:
#if defined(sun) && defined(__SVR4)
To identify SunOS:
#if defined(sun) && !defined(__SVR4)
Both Sun's cc and GNU gcc define these symbols.
--
Jason C. Austin
Web: http://gis-www.larc.nasa.gov/~jason
1. starting off a dos-smtp-''project''
greetings!
I have a certain amount of C/c++/asm etc etc - no big deal...
not anywhere near expert but am willing to tackle this idea.
a c program running in dos that will smtp a text file
from one machine on a network to another smtp server.
the file i/o etc isnt the problem , its where to start
on the smtp networking part that i'd like some words of
guidance on.
of course - as usual , someone has already written this
program and if i can get the person who has done this
and scrounge a copy of him/her ??.....
regards all
A Learner
(aka paul kearney)
3. Is e2label 'dangerous' when done on a 'live' file system?
4. Kernel panic: No init found ?
5. dos won't recognize my extended dos partition
7. Newbie: What's done by 'alog' ?
8. ipx_interface: requested device (eth0) is down ?!?!
9. hung after 'exit()' is called...what's it doing?
10. HELP: Connectivity between DOS/DOS and DOS/Linux
11. Doing 'stty erase ^H' on remote shells
12. How do I get 'w' to say that i am doing something else
13. Cannot mount dos 'd' drive