Connecting Tech Pros Worldwide Forums | Help | Site Map

#define

srinivas reddy
Guest
 
Posts: n/a
#1: Jul 19 '05
I have defined some variables using #define preprocessor instruction.
And then later I checked whether I had defined a variable. Sometimes
even though a variable have been defined, #if !defined(var) construct
is returning true. I am using gcc3.0.1 on SunOS8. I would appreciate
if any body can tell me whether this is a bug or I am doing something
wrong.

tia,
Srinivas

David White
Guest
 
Posts: n/a
#2: Jul 19 '05

re: #define


srinivas reddy <srinivasreddy_m@yahoo.com> wrote in message
news:ff8ef364.0307071857.7d478746@posting.google.c om...[color=blue]
> I have defined some variables using #define preprocessor instruction.
> And then later I checked whether I had defined a variable. Sometimes
> even though a variable have been defined, #if !defined(var) construct
> is returning true. I am using gcc3.0.1 on SunOS8. I would appreciate
> if any body can tell me whether this is a bug or I am doing something
> wrong.[/color]

I would have said that this surely is a bug, but I wouldn't put anything
past the C++ preprocessor.

Incomprehensibly, #if var1 == var2 simply converts var1 and var2 to "0"
(yes, "0", even though the preprocessor is a _text_ replacer) if it hasn't
come across definitions of them (something like Basic assuming that any
undefined variable it comes across must be an int; and I thought C++ got rid
of implicit this and implicit that because they are thought unsafe). 0 == 0
is true, of course.

I can only assume that those with influence who wish to see the end of the
preprocessor altogether are trying to accelerate its death by ensuring that
it works as badly as possible.

DW



Pete Becker
Guest
 
Posts: n/a
#3: Jul 19 '05

re: #define


David White wrote:[color=blue]
>
> I can only assume that those with influence who wish to see the end of the
> preprocessor altogether are trying to accelerate its death by ensuring that
> it works as badly as possible.
>[/color]

Then it must be that the folks who originally came up with the idea of
the preprocessor thirty years ago tried to accelerate its death, because
replacing undefined symbols with 0 in arithmetic expressions has been
the rule since the beginning.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Howard
Guest
 
Posts: n/a
#4: Jul 19 '05

re: #define



"srinivas reddy" <srinivasreddy_m@yahoo.com> wrote in message
news:ff8ef364.0307071857.7d478746@posting.google.c om...[color=blue]
> I have defined some variables using #define preprocessor instruction.
> And then later I checked whether I had defined a variable. Sometimes
> even though a variable have been defined, #if !defined(var) construct
> is returning true. I am using gcc3.0.1 on SunOS8. I would appreciate
> if any body can tell me whether this is a bug or I am doing something
> wrong.
>
> tia,
> Srinivas[/color]

Perhaps you have defined the variable, but not in the compilation unit in
which your #if statement is written? In other words, if you #define the
variable in unit1.h, and make your check in unit2.cpp, then you need to add
#include "unit1.h" in unit2.cpp before checking if the variable exists.

(I usually put my #define's in a precompiled header if they're going to be
widely used in my projects. But that's with CodeWarrior...I don't know how
to use gcc so it may be different.)

Just a thought...

-Howard



Paul Mensonides
Guest
 
Posts: n/a
#5: Jul 19 '05

re: #define


David White wrote:[color=blue]
> srinivas reddy <srinivasreddy_m@yahoo.com> wrote in message
> news:ff8ef364.0307071857.7d478746@posting.google.c om...[color=green]
>> I have defined some variables using #define preprocessor instruction.
>> And then later I checked whether I had defined a variable. Sometimes
>> even though a variable have been defined, #if !defined(var) construct
>> is returning true. I am using gcc3.0.1 on SunOS8. I would appreciate
>> if any body can tell me whether this is a bug or I am doing something
>> wrong.[/color]
>
> I would have said that this surely is a bug, but I wouldn't put
> anything past the C++ preprocessor.
>
> Incomprehensibly, #if var1 == var2 simply converts var1 and var2 to
> "0" (yes, "0", even though the preprocessor is a _text_ replacer) if
> it hasn't come across definitions of them (something like Basic
> assuming that any undefined variable it comes across must be an int;
> and I thought C++ got rid of implicit this and implicit that because
> they are thought unsafe). 0 == 0 is true, of course.
>
> I can only assume that those with influence who wish to see the end
> of the preprocessor altogether are trying to accelerate its death by
> ensuring that it works as badly as possible.[/color]

It isn't the preprocessor that is bad--even the conversion to 0 that you mention
here. It is *misuse* of the preprocessor that is bad. The preprocessor is
actually a critical component of the C and C++ compilation process. It makes it
possible to write code that works on multiple platforms, as well as write code
that works on various current compilers (as opposed to the idealistic perfect
C++ implementation).

Regards,
Paul Mensonides


David White
Guest
 
Posts: n/a
#6: Jul 19 '05

re: #define


Pete Becker <petebecker@acm.org> wrote in message
news:3F0AD150.8B6D2F5E@acm.org...[color=blue]
> David White wrote:[color=green]
> >
> > I can only assume that those with influence who wish to see the end of[/color][/color]
the[color=blue][color=green]
> > preprocessor altogether are trying to accelerate its death by ensuring[/color][/color]
that[color=blue][color=green]
> > it works as badly as possible.
> >[/color]
>
> Then it must be that the folks who originally came up with the idea of
> the preprocessor thirty years ago tried to accelerate its death, because
> replacing undefined symbols with 0 in arithmetic expressions has been
> the rule since the beginning.[/color]

I accept that, but why hasn't it been fixed along with everything else?
Implicit int, matching of function argument types, insistence that function
definitions be present, etc. have been some of the many improvements to C++
since C. I don't think anyone disputes that these are all good things. The
more prgrammer errors you can detect at compile time the better. Why leave
something there that's so obviously bad?

DW



Pete Becker
Guest
 
Posts: n/a
#7: Jul 19 '05

re: #define


David White wrote:[color=blue]
>
> Pete Becker <petebecker@acm.org> wrote in message
> news:3F0AD150.8B6D2F5E@acm.org...[color=green]
> > David White wrote:[color=darkred]
> > >
> > > I can only assume that those with influence who wish to see the end of[/color][/color]
> the[color=green][color=darkred]
> > > preprocessor altogether are trying to accelerate its death by ensuring[/color][/color]
> that[color=green][color=darkred]
> > > it works as badly as possible.
> > >[/color]
> >
> > Then it must be that the folks who originally came up with the idea of
> > the preprocessor thirty years ago tried to accelerate its death, because
> > replacing undefined symbols with 0 in arithmetic expressions has been
> > the rule since the beginning.[/color]
>
> I accept that, but why hasn't it been fixed along with everything else?[/color]

Because it's not broken.
[color=blue]
> Implicit int, matching of function argument types, insistence that function
> definitions be present, etc. have been some of the many improvements to C++
> since C. I don't think anyone disputes that these are all good things. The
> more prgrammer errors you can detect at compile time the better. Why leave
> something there that's so obviously bad?
>[/color]

The fact that you don't understand it doesn't make it bad.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
David White
Guest
 
Posts: n/a
#8: Jul 19 '05

re: #define


Pete Becker <petebecker@acm.org> wrote in message
news:3F0B4B74.39BC048A@acm.org...[color=blue]
> David White wrote:[color=green]
> >
> >
> > I accept that, but why hasn't it been fixed along with everything else?[/color]
>
> Because it's not broken.
>[color=green]
> > Implicit int, matching of function argument types, insistence that[/color][/color]
function[color=blue][color=green]
> > definitions be present, etc. have been some of the many improvements to[/color][/color]
C++[color=blue][color=green]
> > since C. I don't think anyone disputes that these are all good things.[/color][/color]
The[color=blue][color=green]
> > more prgrammer errors you can detect at compile time the better. Why[/color][/color]
leave[color=blue][color=green]
> > something there that's so obviously bad?
> >[/color]
> The fact that you don't understand it doesn't make it bad.[/color]

What have I said that indicates that I don't understand it? Did I describe
it wrongly?

I'm interested to know: do you think that assuming that an undefined
preprocessor symbol is "0" is a good thing, or something that wouldn't be
improved by a compiler error saying that the symbol is undefined? If so, why
not extend the principle to assuming that any symbol in a C++ expression is
an 'int'?

myVariable = 7;
// myVariable not defined anywhere: so it must be an 'int'.

Okay?

myVariable = myFunction(3, "abc", 2.65);
// myFunction not defined anywhere: so it must be int myFunction(int, char
*, double);

Okay?

DW



Pete Becker
Guest
 
Posts: n/a
#9: Jul 19 '05

re: #define


David White wrote:[color=blue]
>
> Pete Becker <petebecker@acm.org> wrote in message
> news:3F0B4B74.39BC048A@acm.org...[color=green]
> > David White wrote:[color=darkred]
> > >
> > >
> > > I accept that, but why hasn't it been fixed along with everything else?[/color]
> >
> > Because it's not broken.
> >[color=darkred]
> > > Implicit int, matching of function argument types, insistence that[/color][/color]
> function[color=green][color=darkred]
> > > definitions be present, etc. have been some of the many improvements to[/color][/color]
> C++[color=green][color=darkred]
> > > since C. I don't think anyone disputes that these are all good things.[/color][/color]
> The[color=green][color=darkred]
> > > more prgrammer errors you can detect at compile time the better. Why[/color][/color]
> leave[color=green][color=darkred]
> > > something there that's so obviously bad?
> > >[/color]
> > The fact that you don't understand it doesn't make it bad.[/color]
>
> What have I said that indicates that I don't understand it? Did I describe
> it wrongly?[/color]

You said earlier that the preprocessor is "a _text_ replacer."
[color=blue]
>
> I'm interested to know: do you think that assuming that an undefined
> preprocessor symbol is "0" is a good thing, or something that wouldn't be
> improved by a compiler error saying that the symbol is undefined?[/color]

No. It would make some things much more verbose, and would only help
beginners.
[color=blue]
> If so, why
> not extend the principle to assuming that any symbol in a C++ expression is
> an 'int'?[/color]

Non sequitur.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
David White
Guest
 
Posts: n/a
#10: Jul 19 '05

re: #define


Pete Becker <petebecker@acm.org> wrote in message
news:3F0B68CC.191AC09E@acm.org...[color=blue]
> David White wrote:[color=green]
> >
> > What have I said that indicates that I don't understand it? Did I[/color][/color]
describe[color=blue][color=green]
> > it wrongly?[/color]
>
> You said earlier that the preprocessor is "a _text_ replacer."[/color]

Yes, and that statement was _clearly_ made in the context of #define and
#if.

#define X Y

Doesn't this replace the symbol 'X' found anywhere in the source code with
the text 'Y'?

Also: "Because they rearrange the program text before the compiler proper
sees it, macros are..." - The C++ Programming Language (3rd ed.), page 160.

Given that macros _do_ replace text, why should an undefined symbol become
'0' rather than ''?
[color=blue][color=green]
> > I'm interested to know: do you think that assuming that an undefined
> > preprocessor symbol is "0" is a good thing, or something that wouldn't[/color][/color]
be[color=blue][color=green]
> > improved by a compiler error saying that the symbol is undefined?[/color]
>
> No. It would make some things much more verbose,[/color]

Such as?

And is the increased verbosity worse than no message from the compiler when
a symbol is used without having been defined?

Speaking of verbosity, the way to ensure that preprocessor symbols are not
silently converted to 0 is:

#if !defined(REACTOR_TYPE) || !defined(REACTOR_NEW_MODEL)
#error REACTOR_TYPE or REACTOR_NEW_MODEL not defined
#endif

Apart from the fact that if one remembers to do this then one would have
ensured that the symbols were defined, is it not verbose to place this in
every source file in which these symbols are used?
[color=blue]
> and would only help
> beginners.[/color]

I see. So, only beginners would ever forget to ensure that both of these are
#defined somewhere?

#if REACTOR_TYPE == REACTOR_NEW_MODEL
[color=blue][color=green]
> > If so, why
> > not extend the principle to assuming that any symbol in a C++ expression[/color][/color]
is[color=blue][color=green]
> > an 'int'?[/color]
>
> Non sequitur.[/color]

void f(int reactorType)
{
// No definition of REACTOR_NEW_MODEL given
if(reactorType == REACTOR_NEW_MODEL)
{
// ...
}
}

Why should this be an error, but not the preprocessor version?

DW



David White
Guest
 
Posts: n/a
#11: Jul 19 '05

re: #define


"Paul Mensonides" <leavings@comcast.net> wrote in message
news:ZoHOa.12065$H17.3639@sccrnsc02...[color=blue]
> David White wrote:[color=green]
> > Incomprehensibly, #if var1 == var2 simply converts var1 and var2 to
> > "0" (yes, "0", even though the preprocessor is a _text_ replacer) if
> > it hasn't come across definitions of them (something like Basic
> > assuming that any undefined variable it comes across must be an int;
> > and I thought C++ got rid of implicit this and implicit that because
> > they are thought unsafe). 0 == 0 is true, of course.
> >
> > I can only assume that those with influence who wish to see the end
> > of the preprocessor altogether are trying to accelerate its death by
> > ensuring that it works as badly as possible.[/color]
>
> It isn't the preprocessor that is bad--even the conversion to 0 that you[/color]
mention[color=blue]
> here.[/color]

Well, I think the conversion to 0 _is_ bad. Given that you can use #ifdef or
#if defined() for things such as:
#ifdef _cplusplus

how can the implicit conversion to 0 of an undefined symbol be a good thing?
Why is it better than issuing an error?
[color=blue]
> It is *misuse* of the preprocessor that is bad. The preprocessor is
> actually a critical component of the C and C++ compilation process.[/color]

I agree. That's why I'd like it to work _safely_.
[color=blue]
> It makes it
> possible to write code that works on multiple platforms, as well as write[/color]
code[color=blue]
> that works on various current compilers (as opposed to the idealistic[/color]
perfect[color=blue]
> C++ implementation).[/color]

Yes, but I want to do it safely. I do not want the outcome of an #if to be
one of these two possibilities:
1. The result of the expression of previously defined symbols.
2. A programmer's mistake in forgetting to include the defined symbols.

This is inherently unsafe. The possibility of no. 2 is the reason that C++
insists on all function definitions being present and that there is a
suitable match for every argument. Does not one other person here think that
this is a problem?

DW



Alexander Terekhov
Guest
 
Posts: n/a
#12: Jul 19 '05

re: #define



David White wrote:
[...][color=blue]
> This is inherently unsafe. The possibility of no. 2 is the reason that C++
> insists on all function definitions being present and that there is a
> suitable match for every argument. Does not one other person here think that
> this is a problem?[/color]

http://groups.google.com/groups?thre...01%40hsv3.UUCP
(Subject: Using a define that hasn't been #defined)

regards,
alexander.

--
"Status quo, you know, that is Latin for ``the mess we're in.''"

-- Ronald Reagan
Ron Natalie
Guest
 
Posts: n/a
#13: Jul 19 '05

re: #define



"David White" <no@email.provided> wrote in message news:KbLOa.8912$eE.124878@nasal.pacific.net.au...
[color=blue]
>
> Doesn't this replace the symbol 'X' found anywhere in the source code with
> the text 'Y'?[/color]

No, it doesn't. Pete is right, you seem not to understand the preprocessor.
[color=blue]
> Given that macros _do_ replace text, why should an undefined symbol become
> '0' rather than ''?[/color]

They do not replace text, they replace tokens.


Paul Mensonides
Guest
 
Posts: n/a
#14: Jul 19 '05

re: #define


Ron Natalie wrote:[color=blue]
> "David White" <no@email.provided> wrote in message
> news:KbLOa.8912$eE.124878@nasal.pacific.net.au...
>[color=green]
>>
>> Doesn't this replace the symbol 'X' found anywhere in the source
>> code with
>> the text 'Y'?[/color]
>
> No, it doesn't. Pete is right, you seem not to understand the
> preprocessor.
>[color=green]
>> Given that macros _do_ replace text, why should an undefined symbol
>> become '0' rather than ''?[/color]
>
> They do not replace text, they replace tokens.[/color]

Even more specifically, they replace macro invocations:

#define X() Y

X // X

Regards,
Paul Mensonides


Paul Mensonides
Guest
 
Posts: n/a
#15: Jul 19 '05

re: #define


David White wrote:
[color=blue][color=green]
>> It isn't the preprocessor that is bad--even the conversion to 0 that
>> you mention here.[/color]
>
> Well, I think the conversion to 0 _is_ bad. Given that you can use
> #ifdef or #if defined() for things such as:
> #ifdef _cplusplus
>
> how can the implicit conversion to 0 of an undefined symbol be a good
> thing? Why is it better than issuing an error?[/color]

Because it is a "reasonable default." Reasonable defaults make code less
verbose. This happens with templates also:

template<class T> void f(int reactorType)
{
// No definition of REACTOR_NEW_MODEL given
if(reactorType == T::REACTOR_NEW_MODEL)
{
// ...
}
}

The compiler will pass this with no problem even though it still parses the
expression, etc.. The reasonable default here is "non-type". The point being
that the language has to deal with unknown names and make assumptions about what
they mean in various places.

That is just the way it is. You know what the behavior is, so writing "safe"
code is up to you to use the language in safe ways. C and C++ certainly don't
protect you from unsafe usage many areas, why should they do that here?

If you changed the behavior to an error, how would you do this in a non-verbose
way:

# if !__cplusplus && __STDC_VERSION__ >= 199901L

You'd have to do something really annoying because you cannot use any
conditional test that uses the name outside the defined operator. You can't
even do this:

#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L

...because that constitutes an error under your model if __STDC_VERSION__ is not
defined. You'd have to separate the test for definition from the conditional
expression:

# if !defined __cplusplus && defined __STDC_VERSION__
# if __STDC_VERSION__ >= 199901L
# // 1
# else
# // 2
# endif
# else
# // 2
# endif

....and that is a code doubler for point 2.

If you changed the behavior to expanding to nil instead of 0, you'd have silent
changes in other ways. You'd also end of seeing a lot of "hacks" like this:

# if !(__cplusplus+0) && (__STDC_VERSION__+0) >= 199901L

In order to simulate the common scenario that we already have built into the
preprocessor.
[color=blue][color=green]
>> It is *misuse* of the preprocessor that is bad. The preprocessor is
>> actually a critical component of the C and C++ compilation process.[/color]
>
> I agree. That's why I'd like it to work _safely_.[/color]

It does work safely if used correctly. I said it before already: The #if and
#elif directives are not designed to implicitly perform the kind of verification
that you want--because that kind of verification (if done by default) is
downright annoying.

Further, the root problem here is 1) forgetting to include a file, or 2) design
error. Assuming that it is just a case of forgetting to include the file that
defines the symbols, there a many ways in which a program can silently change
meaning in C++ by not including a file (e.g. silently choosing different
function overloads or different template specializations).
[color=blue][color=green]
>> It makes it
>> possible to write code that works on multiple platforms, as well as
>> write code that works on various current compilers (as opposed to
>> the idealistic perfect C++ implementation).[/color]
>
> Yes, but I want to do it safely. I do not want the outcome of an #if
> to be one of these two possibilities:
> 1. The result of the expression of previously defined symbols.[/color]

It is totally ill-conceived. You can do what you want reasonably, but you
cannot do what it already does reasonably. You already have the option to do
what you want:

#if defined(REACTOR_TYPE) \
&& defined(REACTOR_NEW_MODEL) \
&& REACTOR_TYPE == REACTOR_NEW_MODEL

You can't go back the other way.
[color=blue]
> 2. A programmer's mistake in forgetting to include the defined
> symbols.
>
> This is inherently unsafe.[/color]

No it isn't _inherently_ unsafe. It can be unsafe in certain contexts, and you
have to be aware of that when you write code. However, the alternative is much
worse. You can simulate what you want with a small amount of code; you cannot
simulate what it already does with a small amount of code.
[color=blue]
> The possibility of no. 2 is the reason
> that C++ insists on all function definitions being present and that
> there is a suitable match for every argument. Does not one other
> person here think that this is a problem?[/color]

C++ does not insist on all function declarations that you've defined in a group
of files be present at each overload resolution--which can cause silent
differences in overload resolution, etc..

Regards,
Paul Mensonides


David White
Guest
 
Posts: n/a
#16: Jul 19 '05

re: #define


Ron Natalie <ron@sensor.com> wrote in message
news:3f0c2841$0$87915$9a6e19ea@news.newshosting.co m...[color=blue]
>
> "David White" <no@email.provided> wrote in message[/color]
news:KbLOa.8912$eE.124878@nasal.pacific.net.au...[color=blue]
>[color=green]
> >
> > Doesn't this replace the symbol 'X' found anywhere in the source code[/color][/color]
with[color=blue][color=green]
> > the text 'Y'?[/color]
>
> No, it doesn't. Pete is right, you seem not to understand the[/color]
preprocessor.

I do. I just didn't use precise enough language in this pedantic place. I am
aware that the 'X' in 'MAX' would not be replaced by 'Y'.
[color=blue][color=green]
> > Given that macros _do_ replace text, why should an undefined symbol[/color][/color]
become[color=blue][color=green]
> > '0' rather than ''?[/color]
>
> They do not replace text, they replace tokens.[/color]

Okay. Why you didn't correct Stroustrup's loose language as well? :)

Getting off the track.

DW



David White
Guest
 
Posts: n/a
#17: Jul 19 '05

re: #define


Alexander Terekhov <terekhov@web.de> wrote in message
news:3F0BEAEE.9995154E@web.de...[color=blue]
>
> David White wrote:
> [...][color=green]
> > This is inherently unsafe. The possibility of no. 2 is the reason that[/color][/color]
C++[color=blue][color=green]
> > insists on all function definitions being present and that there is a
> > suitable match for every argument. Does not one other person here think[/color][/color]
that[color=blue][color=green]
> > this is a problem?[/color]
>
> http://groups.google.com/groups?thre...01%40hsv3.UUCP
> (Subject: Using a define that hasn't been #defined)[/color]

Thanks, Alexander. I am not alone after all.

DW



Sam Holden
Guest
 
Posts: n/a
#18: Jul 19 '05

re: #define


On Thu, 10 Jul 2003 13:35:24 +1000, David White <no@email.provided> wrote:[color=blue]
> Sam Holden <sholden@flexal.cs.usyd.edu.au> wrote in message
> news:slrnbgpln5.fft.sholden@flexal.cs.usyd.edu.au. ..[color=green]
>> On Thu, 10 Jul 2003 12:31:36 +1000,
>> David White <no@email.provided> wrote:[color=darkred]
>> >[/color][/color]
>[color=green]
>> Using #if in anything but a header file is madness in my opinion. I
>> guess using it to give some platform specific optimisation might be OK,
>> but I'd try and find a way to move the #if itself into a header.[/color]
>
> You can't always use C++ itself. How, for example, do you make a declaration
> depend on whether you are compiling a NORMAL or LITE version of the
> software? Suppose you also have EXTRA_LITE and PREMIUM versions. And suppose
> the following constant has a different value for each one:
>
> #if MODEL == EXTRA_LITE
> const int NrWheels = 2;
> #elif MODEL == LITE
> const int NrWheels = 4;
> // etcetera[/color]

By moving those values into the header file, since they are obviously
in some way dependant on the MODEL and hence having them in one place
rather than scattered throughout many source files is nice (even
if they are in fact only used once - it unifies the location of all
such data).

#define MODEL_NRWHEELS 2
or
#define MODEL_NRWHEELS 4

which get set by the appropriate model specific header.

and then

const int NrWheels = MODEL_NRWHEELS;

Has the disadvantage that when the code is changed, sometimes
the model header files will have to be modified as well. But
has the advantage that when adding another model you will
hopefully just have to add the appropriate header file set
a the appropriate define and all the code now works - as opposed
to finding all those #ifs and adding #elif MODEL == NEW_MODEL.
Of course in practice things never work out and you have
to modify a bit of the code.

But I'd personally be using the C++ type system rather than
#defines to tell things apart. I've been bitten by inconsistant
settings in #defines in different compile runs or files in C
too many times.

--
Sam Holden

Paul Mensonides
Guest
 
Posts: n/a
#19: Jul 19 '05

re: #define


David White wrote:[color=blue][color=green]
>> It's not going to change. No matter how much you complain about it.[/color]
>
> Yes, I realized that very quickly. I can't even get anyone here to
> agree that anything needs to be fixed.[/color]

It isn't that I don't agree that the kind of danger you refer to doesn't exist.
Instead, its that I don't consider it a big enough problem to prohibit the
utility of the implicit conversion to 0. IMO, the benefits outweigh the costs.

Regards,
Paul Mensonides


Ron Natalie
Guest
 
Posts: n/a
#20: Jul 19 '05

re: #define



"David White" <no@email.provided> wrote in message news:%G1Pa.1$sI.2864@nasal.pacific.net.au...[color=blue]
> Ron Natalie <ron@sensor.com> wrote in message[/color]
[color=blue]
> I do. I just didn't use precise enough language in this pedantic place. I am
> aware that the 'X' in 'MAX' would not be replaced by 'Y'.[/color]

There's much more to it than that.
[color=blue][color=green]
> > They do not replace text, they replace tokens.[/color]
>
> Okay. Why you didn't correct Stroustrup's loose language as well? :)[/color]

Because Stroustrup wasn't wrong. You were. The only reference to text
on the page you reference says "the preprocessor rearranges the text ..."
He doesn't say anything specific about macro replacment
[color=blue]
> Getting off the track.[/color]

You're the one driving us there.



David White
Guest
 
Posts: n/a
#21: Jul 19 '05

re: #define


"Ron Natalie" <ron@sensor.com> wrote in message
news:3f0d771d$0$87855$9a6e19ea@news.newshosting.co m...[color=blue]
>
> "David White" <no@email.provided> wrote in message[/color]
news:%G1Pa.1$sI.2864@nasal.pacific.net.au...[color=blue][color=green]
> > Ron Natalie <ron@sensor.com> wrote in message[/color]
>[color=green]
> > I do. I just didn't use precise enough language in this pedantic place.[/color][/color]
I am[color=blue][color=green]
> > aware that the 'X' in 'MAX' would not be replaced by 'Y'.[/color]
>
> There's much more to it than that.[/color]

No kidding? I called the preprocessor a "text" replacer while discussing its
replacement of an undefined symbol with "0" instead of with nothing at all.
This was a correct statement. A token is composed of text. Therefore if you
replace a token you are replacing text. Then I gave an example in which my
language was not precise enough and was corrected. I accepted the correction
to the more precise term 'token' and added an example. And now I get,
completely unnecessarily, but perhaps predictably, "There's much more to it
than that". Really? What a revelation. I've just looked up "The C++
Programming Language", and (my God!), the preprocessor also has #include,
which lets you include a whole other file! And it even has macros with
parameters! And a macro can even use another macro! And there are other
things as well!
[color=blue][color=green]
> > Getting off the track.[/color]
>
> You're the one driving us there.[/color]

No, you are, with this ridiculous waste of time.

DW



Closed Thread