POV-Ray : Newsgroups : povray.general : #ifdef using a string expression? : Re: #ifdef using a string expression? Server Time
23 Mar 2023 22:26:01 EDT (-0400)
  Re: #ifdef using a string expression?  
From: Kenneth
Date: 18 Mar 2023 09:05:00
Message: <web.6415b5b098df09c99b4924336e066e29@news.povray.org>
Alain Martel <kua### [at] videotronca> 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

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:

...do this... // success
...do that...

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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.