POV-Ray : Newsgroups : povray.general : #ifdef using a string expression? : Re: #ifdef using a string expression? Server Time
24 Mar 2023 00:19:20 EDT (-0400)
  Re: #ifdef using a string expression?  
From: Alain Martel
Date: 14 Mar 2023 08:54:05
Message: <64106e6d@news.povray.org>
Le 2023-03-14 à 08:43, Kenneth a écrit :
> (v3.8.0 beta 1 in Windows 10)
> I was playing around with #ifdef recently; just experimenting.
> I put a nonsense string expression into it-- not actually defined anywhere-- to
> see what would happen:
> #ifdef("htenneK")
> ....do this...
> #else
> ....do that...
> #end
> Instead of issuing an error message or even a fatal error as I half-way
> expected, it actually fell through to the *first* clause successfully. Without
> the double quotes, it works as expected and falls through to the #else.
> Should #ifdef behave this way? Is the first double-quote causing some kind of
> unforeseen problem for the parser?
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.
Without the quotes, it test if the variable exist, and, if it wasn't 
#declare beforehand, will return false.

So, I think that it behave as it should.

Post a reply to this message

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