c++ - Preprocessor test for equality always evaluates true -



c++ - Preprocessor test for equality always evaluates true -

using this:

-dme=awesome

and this:

#if me==awesome #error im awesome! #endif

yields this:

registers.cpp:59:2: error: #error im awesome!

but this:

#if me==notsogreat #error im confused! #endif

yields this:

registers.cpp:59:2: error: #error im confused!

note doing -dme=awesome equivalent source file starting with:

#define me awesome

now let's @ #if me==awesome. token replacement changes me awesome, final version of line is:

#if awesome==awesome

when utilize == in preprocessor, alphabetic token not #defined else, gets replaced 0. tests #if 0 == 0 true, error displayed.

now, looking at:

#if me==notsogreat

after token replacement is:

#if awesome==notsogreat

which 1 time again equivalent #if 0 == 0, true.

if had #define awesome 5 before this, find first test true sec test false.

i guess trying observe if me had been defined awesome there no way that; can test whether me has been defined equal whatever awesome has been defined as.

c++ preprocessor

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -