By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,934 Members | 1,677 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,934 IT Pros & Developers. It's quick & easy.

How to use the cpponly compiler pragma

P: n/a


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
Share this Question
Share on Google+
8 Replies


P: n/a
"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

P: n/a

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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.