[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

8954.0. "D-UNIX V3.2 / V4.0 C-compilation flags ?" by TAEC::URAGO () Tue Feb 25 1997 10:49

Hi,

I am curently porting C programs from D-UNIX V3.2 to D-UNIXV4.0.

I would like to use an alternative compilation for each system specific
code but keep the same compile command line on both V3.2 and V4.0 (these comands
are documented in customer documentations).

In other words, i would like to do

#ifdef D_UNIX_V4.0

   /* specific V4.0 code */
#else
   /* Specific V3.2 code */
#endif

My question is : is there any predefine C-compilation (D_UNIX_V4.0 in my
example) flags that allows to determine the system Version at compile time ?


Regards
Jean-marie


T.RTitleUserPersonal
Name
DateLines
8954.1DECCXL::MARIOTue Feb 25 1997 12:1423
There are no predefined C compilation flags which will do this for you.

You can always roll your own.  Here's one example:
 
quarry-228% cc a.c -c -DUNIX_V40=`uname -a | grep -c "V3.2"`

If you add -v you can see what the UNIX_V40 macro becomes:

quarry-229% cc a.c -c -DUNIX_V40=`uname -a | grep -c "V3.2"` -v
/usr/lib/cmplrs/cc/gemc_cc -D__LANGUAGE_C__ -D__unix__ -D__osf__ -D__alpha
 -D_SYSTYPE_BSD -D_LONGLONG -DLANGUAGE_C -Dunix -DSYSTYPE_BSD -DUNIX_V40=0
 -I/usr/include -preempt_symbol -g0 -O2 -std0 -o a.o a.c
 

quarry-230% cc a.c -c -DUNIX_V40=`uname -a | grep -c "V4.0"` -v
/usr/lib/cmplrs/cc/gemc_cc -D__LANGUAGE_C__ -D__unix__ -D__osf__ -D__alpha
 -D_SYSTYPE_BSD -D_LONGLONG -DLANGUAGE_C -Dunix -DSYSTYPE_BSD -DUNIX_V40=1
 -I/usr/include -preempt_symbol -g0 -O2 -std0 -o a.o a.c
 
Be careful about defining macros with decimal points in them.  For
example -DVERSION=V3.2 treats V3.2 as two separate preprocessing 
tokens.  You're better off defining the macros to be zero or nonzero
numeric values.