473,503 Members | 1,670 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

#ifdef __SunOS_5.10

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]
May 19 '07 #1
3 2191

"Andrew Gabriel" <an****@cucumber.demon.co.ukwrote in message
news:46*********************@news.aaisp.net.uk...
>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

May 19 '07 #2
an****@cucumber.demon.co.uk (Andrew Gabriel) writes:
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) ks***@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"
May 19 '07 #3
In article <ln************@nuthaus.mib.org>,
Keith Thompson <ks***@mib.orgwrites:
an****@cucumber.demon.co.uk (Andrew Gabriel) writes:
>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 ;-)
<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]
May 19 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2416
by: Christopher M. Lusardi | last post by:
Hello, Is there anyway to do it other than using : #ifdef VAR1 ... #endif
5
5761
by: lovecreatesbeauty | last post by:
Do #ifdef or #ifndef have some defects? I ever heard that some people use #if defined() or #if !defined() instead of using #ifdef or #ifndef in header file.
5
3888
by: Hash | last post by:
I have a small doubt, #ifdef _BSD When we use #ifdef preprocessor directive, the parameter which we pass (in this case _BSD) is it defined by the user or is it defined somewhere else? If...
6
74312
by: Michael B Allen | last post by:
Which is the preferred method for preprocessor tests and why? #ifdef XYZ or #if XYZ or #if defined(XYZ) and
8
2492
by: kk_oop | last post by:
Hi. In our domain, we have to vary a lot of code based on a radar type (of which there are 3--for now). The legacy code acheives this by heavy use of #ifdef macros sprinkled throughout the code. ...
1
3200
by: Michael Sgier | last post by:
Hi I get the error: No case-independent string comparison (stricmp, strcasecmp) with the code below. Why...where should stricmp be defined? And how do i get rid of the error on Linux? // //...
5
3526
by: anushhprabu | last post by:
#include <stdio.h> #include <ctype.h> #define DEBUG 1 main() { char inbuf; int i = 0; int lcnt = 0; gets(inbuf); while(*(inbuf+i))
6
27762
by: anirbid.banerjee | last post by:
Hi, I need to write a macro which would have a lot many conditional #ifdef ... #endif blocks in it. #define _xx_macro (x) { ... \ ... \ /* some code (); */ #ifdef _SOME_STMT \ ... \ ... \
10
3501
by: David W | last post by:
Hello, In a C++ MFC application I need to conditionally #include one of two additional resource files in my main resource file because different forms of the application have different names. I...
0
7201
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7083
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6988
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7456
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3166
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.