I'm trying to maintain some older C code (FOSS) which has been
patched by various individuals over the years for portability to
multiple Unix-like operating systems, to wit: Linux, SunOS,
Solaris, Free/Open/NetBSD, Mac OS X, AT&T SysV r4, SCO Unix, AIX,
OSF, NextStep.
I want to add some conditionals like this:
#if defined(USECODE _A)
/*use this code */
#elif defined(USECODE _B)
/*use this code */
#elif defined(USECODE _C)
/*use this code */
#elif defined(USECODE _D)
/*use this code */
#else
/*use this code*/
#endif
However although in the existing code there are numerous
"#if/#else/#endif" conditionals with what seems like awkward
nesting, nowhere do I find "#elif" used.
K&R 2nd edition (1988) says #elif is new since the 1978 edition.
How likely is there to be a portability problem if I use #elif ?
Thanks for your advice.
Regards,
Charles Sullivan 2 2598
On Feb 23, 9:40 pm, Charles Sullivan <cwsul...@triad .rr.comwrote:
I'm trying to maintain some older C code (FOSS) which has been
patched by various individuals over the years for portability to
multiple Unix-like operating systems, to wit: Linux, SunOS,
Solaris, Free/Open/NetBSD, Mac OS X, AT&T SysV r4, SCO Unix, AIX,
OSF, NextStep.
I want to add some conditionals like this:
#if defined(USECODE _A)
/*use this code */
#elif defined(USECODE _B)
/*use this code */
#elif defined(USECODE _C)
/*use this code */
#elif defined(USECODE _D)
/*use this code */
#else
/*use this code*/
#endif
However although in the existing code there are numerous
"#if/#else/#endif" conditionals with what seems like awkward
nesting, nowhere do I find "#elif" used.
K&R 2nd edition (1988) says #elif is new since the 1978 edition.
How likely is there to be a portability problem if I use #elif ?
#elif has been around since the early 1980s. It was supported by
many, if not most, compilers by the late 1980s as it was present in
the ANSI C draft, any Standard conforming implementation will support
it. If you don't care about supporting pre-ANSI compilers there is
nothing to worry about, but if you do then you can't assume #elif will
be available in all cases.
Robert Gamble
On Fri, 23 Feb 2007 19:17:10 -0800, Robert Gamble wrote:
On Feb 23, 9:40 pm, Charles Sullivan <cwsul...@triad .rr.comwrote:
>I'm trying to maintain some older C code (FOSS) which has been patched by various individuals over the years for portability to multiple Unix-like operating systems, to wit: Linux, SunOS, Solaris, Free/Open/NetBSD, Mac OS X, AT&T SysV r4, SCO Unix, AIX, OSF, NextStep.
I want to add some conditionals like this:
#if defined(USECODE _A) /*use this code */ #elif defined(USECODE _B) /*use this code */ #elif defined(USECODE _C) /*use this code */ #elif defined(USECODE _D) /*use this code */ #else /*use this code*/ #endif
However although in the existing code there are numerous "#if/#else/#endif" conditionals with what seems like awkward nesting, nowhere do I find "#elif" used.
K&R 2nd edition (1988) says #elif is new since the 1978 edition.
How likely is there to be a portability problem if I use #elif ?
#elif has been around since the early 1980s. It was supported by
many, if not most, compilers by the late 1980s as it was present in
the ANSI C draft, any Standard conforming implementation will support
it. If you don't care about supporting pre-ANSI compilers there is
nothing to worry about, but if you do then you can't assume #elif will
be available in all cases.
Robert Gamble
Thanks Robert. I think I'll go ahead and use it. If anyone squawks
then I'll know there are users with antique compilers who are
still using the software and I can deal with them individually.
Regards,
Charles Sullivan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: pemo |
last post by:
Is C really portable? And, apologies, but this is possibly a little OT?
In c.l.c we often see 'not portable' comments, but I wonder just how
portable C apps really are.
I don't write portable C code - *not only* because, in a 'C sense', I
|
by: Jim |
last post by:
Could somebody tell me why I need the "elif char == '\n'" in the
following code?
This is required in order the pick up lines with just spaces in them.
Why doesn't
the "else:" statement pick this up?
OLD_INDENT = 5 # spaces
NEW_INDENT = 4 # spaces
print 'Reindent.py:'
|
by: lostsoul |
last post by:
Hi All,
I am new in learning programming. I am very lost. I read all of the chapters over and over again and I am still lost. I have the program below that I need to modify it to add hint to it when the user couldn't figure out the jumble word. Somehow the program didn't run. Can someone please look at it and enlighten me to see what I am missing? Is there any advise in learning and improving my programming skill? I am very disappointed at...
|
by: juan-manuel.behrendt |
last post by:
Hello together,
I wrote a script for the engineering software abaqus/CAE. It worked
well until I implemented a selection in order to variate the variable
"lGwU" through an if elif, else statement. I am going to post the
first 82 lines of the script, since the error message points at line
80:
from abaqusConstants import *
from abaqus import *
|
by: jacob navia |
last post by:
I am trying to compile as much code in 64 bit mode as
possible to test the 64 bit version of lcc-win.
The problem appears now that size_t is now 64 bits.
Fine. It has to be since there are objects that are more than 4GB
long.
The problem is, when you have in thousands of places
| |
by: Shawn Minisall |
last post by:
I just learned about if, then elif statements and wrote this program.
The problem is, it's displaying all of the possibilities even after you
enter a 0, or if the fat grams are more then the total number of
calories , that is supposed to stop the program instead of continuing on
with the print statements that don't apply. Any idea's? thanks
#Prompt for calories
cal = input("Please enter the number of calories in your food: ")
...
|
by: bvdet |
last post by:
We are parametrically attaching a bent plate object to the side of a building column for support of a skewed beam. Given a relative rotation between the column and beam and which side of the column to attach to, the following code determines the X and Y direction flags to calculate the exact location and the rotation tuple of the bent plate object. Here's the old code (about 5 years old):if _relrotation > 0.0 and _relrotation < 90.0:
...
|
by: Neil Webster |
last post by:
Hi all,
I'm sure I'm doing something wrong but after lots of searching and
reading I can't work it out and was wondering if anybody can help?
I've got the following block of code:
if a >= 20 and a < 100:
if c == "c":
radius = 500
else:
|
by: Kid Programmer |
last post by:
Hello guys. I was wondering if you could use a thing in python in java. That is an elif statement. It is saying else if. It will execute a block of code if the condition in the if statement is false and the condition in the elif statement is true. So can you do this?
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |