conditional compilation

conditional compilation

Post by stuart.rei.. » Wed, 17 Jan 2001 18:28:02



All,

I have some code which needs to compile on solaris 2.5.1 and
solaris 2.7. There are some minor probs with RPC code which
could easily be solved with some conditional compilations

Is the some #define somewhere which I can use to differentiate
between the two OS.

ie

#ifdef SOL_251
Do solaris 2.5.1 code
#else
Do solaris 2.7 code
#endif

I working on Sun sparc workstation, using SC5.0 compiler.

Any help much appreciated

Regards
Stuart

Sent via Deja.com
http://www.deja.com/

 
 
 

conditional compilation

Post by Vic Abe » Wed, 17 Jan 2001 19:05:16



Quote:>I have some code which needs to compile on solaris 2.5.1 and
>solaris 2.7. There are some minor probs with RPC code which
>could easily be solved with some conditional compilations
>Is the some #define somewhere which I can use to differentiate
>between the two OS.
>ie
>#ifdef SOL_251
>Do solaris 2.5.1 code
>#else
>Do solaris 2.7 code
>#endif
>I working on Sun sparc workstation, using SC5.0 compiler.

You can derive a defined symbol from the output of uname -r.

 
 
 

conditional compilation

Post by Joep Vesse » Wed, 17 Jan 2001 19:21:56



>Is the some #define somewhere which I can use to differentiate
>between the two OS.

the Sun compiler defines a macro

   __`uname -s`_`uname -r`

Look at the output of 'cc -#' to see what is defined.

Joep

 
 
 

conditional compilation

Post by Casper H.S. Dik - Network Security Engine » Wed, 17 Jan 2001 19:33:53


[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]


>I have some code which needs to compile on solaris 2.5.1 and
>solaris 2.7. There are some minor probs with RPC code which
>could easily be solved with some conditional compilations

What type of problems?

[ Perhaps it could be resolved w/o resorting to this ]

Quote:>Is the some #define somewhere which I can use to differentiate
>between the two OS.

It's usually better to defien your own feature macro that
says "FOO_WORKS_DIFFERENTLY" so you can catch all such cases
rather than depnding on an SO define.

Newer versions of the Sun compiler define __SunOS_5_X
which is only marginally useful.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

conditional compilation

Post by Andrew Gabri » Wed, 17 Jan 2001 21:01:30




Quote:> All,

> I have some code which needs to compile on solaris 2.5.1 and
> solaris 2.7. There are some minor probs with RPC code which
> could easily be solved with some conditional compilations

> Is the some #define somewhere which I can use to differentiate
> between the two OS.

It's much better to do this at runtime if you can, so you
only have one binary to make/maintain/distribute. man -s 2 uname

This depends on you actually being able to compile what you
want to do on solaris 2.5.1, even though it will only work
on solaris 7 (which isn't always possible).

--
Andrew Gabriel

 
 
 

conditional compilation

Post by stuartrei.. » Wed, 17 Jan 2001 22:16:52





> [[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]


> >I have some code which needs to compile on solaris 2.5.1 and
> >solaris 2.7. There are some minor probs with RPC code which
> >could easily be solved with some conditional compilations

> What type of problems?

> [ Perhaps it could be resolved w/o resorting to this ]

> >Is the some #define somewhere which I can use to differentiate
> >between the two OS.

> It's usually better to defien your own feature macro that
> says "FOO_WORKS_DIFFERENTLY" so you can catch all such cases
> rather than depnding on an SO define.

> Newer versions of the Sun compiler define __SunOS_5_X
> which is only marginally useful.

> Casper
> --
> Expressed in this posting are my opinions.  They are in no way related
> to opinions held by my employer, Sun Microsystems.
> Statements on Sun products included here are not gospel and may
> be fiction rather than truth.
> The actual problem I am having is that svc_getargs has different

paramaters depending on which OS you are using

I COULD use

#ifdef __SunOS_5_7
svc_getargs( transp, (int(*)(XDR*,void*))xdr_rpc_xml, data )
#elsif
svc_getargs( transp, (int(*)())xdr_rpc_xml, data )
#endif

Not the best solution the world has ever seen !!!

This is all because this piece of code has been added in xdr.h

#ifdef __cplusplus
typedef bool_t (*xdrproc_t)(XDR *, void *);
#else
...

Which doesn't exisist in previous versions of the same file.

Any suggestions ?

Sent via Deja.com
http://www.deja.com/