Does "#if 1 func1 #else func2 #endif execute func1 during executation?

M

Mr. Ken

In the file I received, it defines two versions of same function with such
statement.
Is it during compilation, func1 will be used?

#if 1
func1.....
#else
func1.....
#endif

Sorry for the silly question but I am a little confused now.
 
B

Bart

Mr. Ken said:
In the file I received, it defines two versions of same function with such
statement.
Is it during compilation, func1 will be used?

#if 1
func1.....
#else
func1.....
#endif

Sorry for the silly question but I am a little confused now.

Here the first version (#if 1) will be compiled and the second version
(#else) will be ignored. The function will not be used at compile time.
This is just a way to compile a different version of the function.

Regards,
Bart.
 
M

Mr. Ken

Bart said:
Here the first version (#if 1) will be compiled and the second version
(#else) will be ignored. The function will not be used at compile time.
This is just a way to compile a different version of the function.

Regards,
Bart.

Thank you Bart.
 
B

bharath.donnipad

Mr. Ken said:
Thank you Bart.

Code under #if 1 always compiles and gets embedded in to object file.
You may find #if 0 in some code where in the code under it will not
compile.

- Bharath
 

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,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top