|
 |
Alain Martel <kua### [at] videotron ca> wrote:
> >
> As I see it, #ifdef() test the existence of an entity.
> With the quotes, the string DO exist, IS defined, even if it only exist
> locally. So, the test returns true...
>
> So, I think that it behave as it should.
Sorry for the delay in responding; I had to think about this behavior for
awhile.
I guess it must certainly be so, and I sort of sense the logic of it...but it
does seem odd: The string expression is considered to have been created WITHIN
the #ifdef() itself? What seems strange to me is that #ifdef is not the same
'kind' of code construct as a #declare or #local, which would otherwise be
required earlier for any other kind of entity or variable for #ifdef to operate
on. Although, a string expression is not really a 'variable'; here, it exists as
a 'literal'. Yet a 'naked' string literal cannot be used by itself as a line of
code; that produces an obvious fatal error.
So is a string expression the only kind of 'thing' that #ifdef sees as defined?
Nope. Even an arbitrary float value behaves the same way:
#ifdef(7.6)
...do this... // success
#else
...do that...
#end
To me, this would seem to be an unexpected trap, waiting to be 'exploited' by
mistake. I'm not sure how such a mistake might be made by a user, but still...
My two-cents ;-)
Post a reply to this message
|
 |