473,396 Members | 2,158 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.

How to use the cpponly compiler pragma



Hi,

I just want to know how to use the the CPPONLY pragma which causes only
the C macro preprocessor to be run. Can you specify an example.
Thanks in advance

Nov 3 '06 #1
8 1446
"kris" <ra**************@gmail.comwrites:
I just want to know how to use the the CPPONLY pragma which causes only
the C macro preprocessor to be run. Can you specify an example.
There is no CPPONLY pragma in standard C. It may be some
compiler-specific extension.

Followups redirected.

--
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.
Nov 3 '06 #2

Then how can we obtain a preprocessed output of a programm using a
standard c-compiler.

kris wrote:
Hi,

I just want to know how to use the the CPPONLY pragma which causes only
the C macro preprocessor to be run. Can you specify an example.
Thanks in advance
Nov 3 '06 #3
kris wrote:
Then how can we obtain a preprocessed output of a programm using a
standard c-compiler.
It depends on the C compiler. For example, gcc has a -E option which
says "just preprocess things".

Glenn

Nov 3 '06 #4
2006-11-03 <11**********************@e3g2000cwe.googlegroups. com>,
Glenn Hutchings wrote:
kris wrote:
>Then how can we obtain a preprocessed output of a programm using a
standard c-compiler.

It depends on the C compiler. For example, gcc has a -E option which
says "just preprocess things".
Rarely, using the preprocessor output will yield different results. For
example,

#define N 0xE

main() {
printf("%d\n",N+1);
return 0;
}

The output will be 15, but if the preprocessor intermediate output is
taken, we have the token 0xE+1 in source, which is an invalid number.
gcc -E seems to get around this by adding a space, but is this legal?
Nov 3 '06 #5
Jordan Abel <ra****@random.yi.orgwrites:
2006-11-03 <11**********************@e3g2000cwe.googlegroups. com>,
Glenn Hutchings wrote:
kris wrote:
Then how can we obtain a preprocessed output of a programm using a
standard c-compiler.
It depends on the C compiler. For example, gcc has a -E option which
says "just preprocess things".

Rarely, using the preprocessor output will yield different results. For
example,

#define N 0xE

main() {
printf("%d\n",N+1);
return 0;
}

The output will be 15, but if the preprocessor intermediate output is
taken, we have the token 0xE+1 in source, which is an invalid number.
gcc -E seems to get around this by adding a space, but is this legal?
The standard does not describe the preprocessor as processing text but
as processing tokens. gcc -E gives a textual output which when
tokenized provide the same streams of tokens as preprocessing the
original file.

Yours,

--
Jean-Marc
Nov 3 '06 #6
2006-11-03 <px*************@news.bourguet.org>,
Jean-Marc Bourguet wrote:
Jordan Abel <ra****@random.yi.orgwrites:
>2006-11-03 <11**********************@e3g2000cwe.googlegroups. com>,
Glenn Hutchings wrote:
kris wrote:
Then how can we obtain a preprocessed output of a programm using a
standard c-compiler.

It depends on the C compiler. For example, gcc has a -E option which
says "just preprocess things".

Rarely, using the preprocessor output will yield different results. For
example,

#define N 0xE

main() {
printf("%d\n",N+1);
return 0;
}

The output will be 15, but if the preprocessor intermediate output is
taken, we have the token 0xE+1 in source, which is an invalid number.
gcc -E seems to get around this by adding a space, but is this legal?

The standard does not describe the preprocessor as processing text but
as processing tokens.
I think it does describe how whitespace is treated. Comments, for
example, are defined as expanding to a space, _not_ as being an
invisible token splitter. I don't think macro expansions are defined as
being expanded surrounded by whitespace, "if necessary" or otherwise.
Now, the only way to tell is to use the stringize operator, so let's
come up with an example

#define N 0xE
#define s(x) #x
#define S(x) s(x)
S(a/**/b)
S(N+1)

is the case I was thinking of, but GCC seems to handle this properly. We
have "a b" and "0xE+1".
gcc -E gives a textual output which when tokenized provide the same
streams of tokens as preprocessing the original file.
And it seems smart enough to only do it when there can be no visible
difference (i.e. not under stringize). That was what I was worried
about. Anyway, other compilers might not be as smart, and using the
"preprocessor only" output may result in text output that cannot be
retokenized properly.
Nov 3 '06 #7
On 2 Nov 2006 22:26:44 -0800, "kris" <ra**************@gmail.com>
wrote:
>
Then how can we obtain a preprocessed output of a programm using a
standard c-compiler.
You start by reading the documentation for whatever compiler you're
using.
>

kris wrote:
>Hi,

I just want to know how to use the the CPPONLY pragma which causes only
the C macro preprocessor to be run. Can you specify an example.
Thanks in advance
--
Al Balmer
Sun City, AZ
Nov 3 '06 #8
Jordan Abel <ra****@random.yi.orgwrites:
The standard does not describe the preprocessor as processing text but
as processing tokens.

I think it does describe how whitespace is treated. Comments, for
example, are defined as expanding to a space, _not_ as being an
invisible token splitter.
There are some place where the presence of whitespace (if my memory is
good, comments are white space for that purpose) is significant but it
doesn't go further than that. One hint is the presence of the ##
operator.
I don't think macro expansions are defined as being expanded
surrounded by whitespace, "if necessary" or otherwise.
They are defined as producing a sequence of (preprocessing) tokens.
And it seems smart enough to only do it when there can be no visible
difference (i.e. not under stringize). That was what I was worried
about. Anyway, other compilers might not be as smart, and using the
"preprocessor only" output may result in text output that cannot be
retokenized properly.
Some compilers have the preprocessor as a separate programs which feed
the compiler, these must have a correct preprocessor.

Yours,

--
Jean-Marc
Nov 3 '06 #9

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

Similar topics

2
by: Ágoston Bejó | last post by:
Hi there, In the old Pascal-times, you could set compiler switches in the source code, with a syntax like {$G+}, things like that (I don't remember them accurately anymore). Is there something...
7
by: Matthew Del Buono | last post by:
Don't try to solve the problem. I've found a way -- around or fixing it. I'm just curious as to whether this is Microsoft's problem in their compiler or if there's a standard saying this is to be...
8
by: karunesh | last post by:
why this #pragma use very extnsivly please tell me the usses thaks!! Regards, Karuensh
5
by: venkat | last post by:
Hi, I have come across the a pragma definition " #pragma switch direct ". I don't know any thing about pragma's. Even i when i search through google not getting exact information. what does...
3
by: Oops-c++ | last post by:
All, I came to know that, we can define #pragma variables to share values between the processes. #pragma data_seg(".shared") var1 variable2 #pragma data_seg()
7
by: Studlyami | last post by:
Okay I have been wondering this for a while now. I am a little confused on the difference between these two defines #pragma once & #ifndef. From my understanding #pragma is compiler...
5
by: parag_paul | last post by:
is there any compiler directive that will enforce optimizations?
0
debasisdas
by: debasisdas | last post by:
PRAGMA:-Signifies that the statement is a pragma (compiler directive). Pragmas are processed at compile time, not at run time. They pass information to the compiler. A pragma is an instruction to...
5
by: raashid bhatt | last post by:
What is #pragma once used for and what is #WIN#@_LEN_AND_MEAN
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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
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...
0
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,...

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.