• Advertisement
Sign in to follow this  

Question about Preprocessor Directive

This topic is 4608 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello all. I found some source code with Preprocessor Directive "#if" and I did't understand. Like this: #if 0 #ifndef DotProduct #if ASM #pragma warning (disable: 4035) //__declspec( naked ) float __cdecl DotProduct(const vec3_t v1, const vec3_t v2); #pragma warning( default: 4035 ) #else #ifdef WIN32 float __cdecl DotProduct(const vec3_t v1, const vec3_t v2); #else float DotProduct(const vec3_t v1, const vec3_t v2); #endif #endif #endif #endif what is the "#if 0" means? thanks for help :)

Share this post


Link to post
Share on other sites
Advertisement
Think of them like if() statements executed before compilation in order to include or exclude cerain portions of code.

#IF X means if X is defined && X != 0

Here it is indented so it's easier to see what's going on.

It looks like whoever wrote this wanted to disable the code without removig it
or commenting it out for some reason.

#if 0
#ifndef DotProduct
#if ASM
#pragma warning (disable: 4035)
//__declspec( naked )
float __cdecl DotProduct(const vec3_t v1, const vec3_t v2);
#pragma warning( default: 4035 )
#else
#ifdef WIN32
float __cdecl DotProduct(const vec3_t v1, const vec3_t v2);
#else
float DotProduct(const vec3_t v1, const vec3_t v2);
#endif
#endif
#endif
#endif



Share this post


Link to post
Share on other sites
It can be used for debugging purposes. Zero is false so that code won't run. If you did #if 1 then it would. You can use this to comment out a bunch of code that you want commented out for testing purposes.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement