473,396 Members | 2,050 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,396 software developers and data experts.

a question about preprocessor

I tried the following code and complied in g++

#include <iostream>
using namespace std;

int main()
{
#ifdef __cplusplus
cout << "c++ program" << endl;
#endif

#ifdef __STDC__
cout << "c program" << endl;
#endif

return 0;
}

the output is
c++ program
c program

So both __cplusplus & __STDC__ are defined. But from C++ Primer I read
that only one of them will be defined in a program. What's wrong with my
code/result?

Thanks.

X
Jul 22 '05 #1
1 1022
xuatla wrote:
[...]
So both __cplusplus & __STDC__ are defined. But from C++ Primer I read
that only one of them will be defined in a program. What's wrong with my
code/result?


Everything is right. For a C++ program, __cplusplus is required to be
defined. __STDC__ is required for C programs. For C++, __STDC__
is still allowed, but not required.

Denis
Jul 22 '05 #2

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

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
1
by: Dan W. | last post by:
I've been acting as messenger the past few days between the BOOST and Digital Mars peoples, and they can't seem to come to an agreement about the semantics of using ## vs. juxtaposition. The...
10
by: Steven T. Hatton | last post by:
# -- "If our hypothesis is about anything and not about some one or more particular things, then our deductions constitute mathematics. Thus mathematics may be defined as the subject in which we...
4
by: ethan | last post by:
Hi All, I'd like ask some question about macro. If I define a variable set, such as {5, 2, 10} or {1,3}. #define X {5,2,10} 1) Is it possible to write a macro to get the number of items...
6
by: ludovicd | last post by:
Hi to all, There is my question, Let's say I got a fonction which takes a numeric argument long enough so that there has to be spaces in it to represent it correctly. (Ex. 0xf63a002c5ff0338ec...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
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
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...

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.