Connecting Tech Pros Worldwide Forums | Help | Site Map

#ifdef __SunOS_5.10

Andrew Gabriel
Guest
 
Posts: n/a
#1: May 19 '07
I want to pick up the OS release during compilation in order to
make up for something which is missing from a header file in a
certain release. The Sun C compiler provides a built in predefinition

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

and as an example, echo __`uname -s`_`uname -r` gives:

__SunOS_5.10

So in my code I have:

#ifdef __SunOS_5.10
/* typedef missing from headerfile */
typedef char *x;
#endif

However, this fails because the "." is treated as the end of the
token, and the excess tokens on the line generate a warning. I've
tried some other varients such as

#ifdef "__SunOS_5.10"

#ifdef __SunOS_5\.10

but these don't work either. Is there a way to do this?
I'm trying to avoid adding any further command line -D's as that's
generated by complex makefiles which I'm not allowed to change.

--
Andrew Gabriel
[email address is not usable -- followup in the newsgroup]

Malcolm McLean
Guest
 
Posts: n/a
#2: May 19 '07

re: #ifdef __SunOS_5.10



"Andrew Gabriel" <andrew@cucumber.demon.co.ukwrote in message
news:464f71f6$0$639$5a6aecb4@news.aaisp.net.uk...
Quote:
>I want to pick up the OS release during compilation in order to
make up for something which is missing from a header file in a
certain release. The Sun C compiler provides a built in predefinition
>
__`uname -s`_`uname -r`
>
and as an example, echo __`uname -s`_`uname -r` gives:
>
__SunOS_5.10
>
So in my code I have:
>
#ifdef __SunOS_5.10
/* typedef missing from headerfile */
typedef char *x;
#endif
>
However, this fails because the "." is treated as the end of the
token, and the excess tokens on the line generate a warning. I've
tried some other varients such as
>
#ifdef "__SunOS_5.10"
>
#ifdef __SunOS_5\.10
>
but these don't work either. Is there a way to do this?
I'm trying to avoid adding any further command line -D's as that's
generated by complex makefiles which I'm not allowed to change.
>
--
Andrew Gabriel
[email address is not usable -- followup in the newsgroup]
I suspect that you have two definitions there, one a string and one a
number.
You need to put in a #if uname-r == 5.10. However uname-r probably won't be
the identifier to use, Sun will have provided something with a name like
VERSION_
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Keith Thompson
Guest
 
Posts: n/a
#3: May 19 '07

re: #ifdef __SunOS_5.10


andrew@cucumber.demon.co.uk (Andrew Gabriel) writes:
Quote:
I want to pick up the OS release during compilation in order to
make up for something which is missing from a header file in a
certain release. The Sun C compiler provides a built in predefinition
>
__`uname -s`_`uname -r`
>
and as an example, echo __`uname -s`_`uname -r` gives:
>
__SunOS_5.10
No, the Sun C compiler doesn't provide this particular predefined
symbol. It couldn't, since such a symbol is illegal.

<OT>
"cc -### nosuchfile.c" will show you which symbols are predefined.
One of those symbols is "__SunOS_5_10", which is a legal identifier.
</OT>

Note that identifiers starting with "__" are reserved to the
implementation. Here, it's being defined by the implementation, which
is perfectly correct. If you tried to define such an identifier
yourself, you'd be infringing on the implementation's namespace, with
potentially dangerous consequences.

If you have questions about C, this is the right place. If you have
questions about the behavior of Sun's C compiler, you'll get better
help in comp.unix.solaris.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Andrew Gabriel
Guest
 
Posts: n/a
#4: May 20 '07

re: #ifdef __SunOS_5.10


In article <lnhcq8mp8f.fsf@nuthaus.mib.org>,
Keith Thompson <kst-u@mib.orgwrites:
Quote:
andrew@cucumber.demon.co.uk (Andrew Gabriel) writes:
Quote:
>I want to pick up the OS release during compilation in order to
>make up for something which is missing from a header file in a
>certain release. The Sun C compiler provides a built in predefinition
>>
> __`uname -s`_`uname -r`
>>
>and as an example, echo __`uname -s`_`uname -r` gives:
>>
> __SunOS_5.10
>
No, the Sun C compiler doesn't provide this particular predefined
symbol. It couldn't, since such a symbol is illegal.
OK, the manpage is wrong then ;-)
Quote:
<OT>
"cc -### nosuchfile.c" will show you which symbols are predefined.
One of those symbols is "__SunOS_5_10", which is a legal identifier.
</OT>
Thanks, that works!

--
Andrew Gabriel
[email address is not usable -- followup in the newsgroup]
Closed Thread