473,411 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Who defines the platform specific macros eg LINUX VXWORKS etc

Are these macros defined in Makefile or by some environment which can
detect the platform types?

/* common code here */

#ifdef LINUX

/* other os spefic code */

#elif defined VXWORKS

/* other os spefic code */

#elif defined MACOSX

/* other os spefic code */

#elif defined WIN32

/* other os spefic code */

#endif

/* common code here */
Oct 31 '08 #1
1 4108
lo***************@gmail.c0m wrote:
Are these macros defined in Makefile or by some environment which can
detect the platform types?

/* common code here */

#ifdef LINUX

/* other os spefic code */

#elif defined VXWORKS

/* other os spefic code */

#elif defined MACOSX

/* other os spefic code */

#elif defined WIN32

/* other os spefic code */

#endif

/* common code here */
There is no one answer to that. They can be defined in user code. Most
compilers provide some mechanism for pre-defining some identifiers
before the code is processed. For instance, all of the compilers I use
would accept a "-DLINUX" option which has the same effect as

#define LINUX

or a "-DLINUX=1' option which has the same effect as

#define LINUX 1

However, it often happens that make files will set these options as part
of the build script for your program. POSIX make files (I'm not familiar
with non-POSIX make files, if there are such things) allow you to define
make variables, which are often used to store such options, and any such
variable that is not explicitly set by the make file is implicitly
filled in by using the value of an environment variable of the same
name. Therefore, while the environment and the make file do not set
these macros, they both typically play a role in getting them set.

In short, there's no simple answer to your question. About the only
possibility that does not exist is that a fully conforming C compiler
would pre-define any of these macros itself. Those names all are from
the name space reserved for users, so a conforming implementation can't
predefine them.
Oct 31 '08 #2

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

Similar topics

2
by: Thomas Weholt | last post by:
Hi, I've been using Python on both Windows 2000 and Linux for some time now. On Windows I've used PythonWin as editor, Emacs on Linux. This has been working ok so far. Now as Python will be a...
16
by: LeTubs | last post by:
Hi All I'm just checking if my assumptions are correct If I have the following line #define CLIENT_MSG_HELLO 9 I know the define will be stored in a memory location, but what will it be...
34
by: Sachin Garg | last post by:
I know that language choices are more of a religious choice, rather than a logical decision for many of us. Anyway, here is my concern (which will hopefully not be considered a troll) :-) I have...
8
by: flyingleon | last post by:
I have today downloaded gcc-4.1.1 and tried to configure and build it. I have successfully done this before with gcc-3.4.2. The gcc-4.1.1 includes gfortran which is a language that I need. The...
1
by: /M | last post by:
Hi! As you know, one way to seperate platform dependent code from platform _independent_ code is to create an abstract base class which acts as an interface towards all platform independent code...
22
by: David T. Ashley | last post by:
I'm writing code which will compile on multiple Windows and multiple *nix platforms. Some will have 64-bit integers, I believe. What is my best option to define platform-independent types such...
12
by: Udhay | last post by:
I am new to vc++. Whether Visual Studio is a platform independent? Is there any chance of using my application created by vc in MAC or Linux. udhay
6
by: greek_bill | last post by:
Hi, I'm interested in developing an application that needs to run on more than one operating system. Naturally, a lot of the code will be shared between the various OSs, with OS specific...
1
by: deepakNagpal | last post by:
hi, this is deepak, i got stuck in a script where i want to apply a platform specific css. i will be greatful if anyone could help me out. My PHP code is: <?php $agent =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
isladogs
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...

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.