"#if" with no condition

T

tomy

Hi Group:
The confusing code is as below:
//-------------------------------------------------
#if
#define FOO foo
#else
#define FOO foobar
#endif
//-------------------------------------------------

Could the "#if" be with no following expression? However, the code
can't be compiled (gcc). Does any new C stardard defne THIS new method
about "#if"? Or it just equal to #if 0 ??

--tomy
 
R

Robert Gamble

tomy said:
Hi Group:
The confusing code is as below:
//-------------------------------------------------
#if
#define FOO foo
#else
#define FOO foobar
#endif
//-------------------------------------------------

Could the "#if" be with no following expression? However, the code
can't be compiled (gcc). Does any new C stardard defne THIS new method
about "#if"? Or it just equal to #if 0 ??

An #if directive requires a constant expression, your example is not
valid C.

Robert Gamble
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top