Sunny
Sunny

Reputation: 7614

C: How to enable __<Flag_Name>__

I have the following piece of code:

#ifdef __SYM_TRACE__
#define SYM_TRACE( L, F )   { SETTRACE_LEVEL(L); tracefunc F; }
#define SYM_TRACE2( F )     { SETTRACE_LEVEL(SYM_MODULE); tracefunc F; }
#else
#define SYM_TRACE( L, F )
#define SYM_TRACE2( F )
#endif

Now the issue is that where would I find the SYM_TRACE flag and how do I enable it? There is no macro in the code by the name of SYM_TRACE, so where is this getting picked from?

Also, another beginner question. Could someone please explain the significance of __ before and after the macro name.

Thanks, Sunny

Upvotes: 0

Views: 142

Answers (2)

Ishmeet
Ishmeet

Reputation: 1610

__SYM_TRACE__ 

is probably defined in your make file, and __ is just the name, I dont think that has a significance, maybe it does during porting on other platforms. Most C compilers accept the option -D to define a symbol:

gcc -D__SYM_TRACE__ file.c

Upvotes: 1

Dayal rai
Dayal rai

Reputation: 6606

Answer is already there so consider it just as addition

You can do following option to enable __SYM_TRACE__

write #define __SYM_TRACE__ in header file which is getting used with shown piece of code.(Do not forget to guard it with #ifndef endif)

You can add it in Makefile as suggested by @Ishmeet using -D__SYM_TRACE__

Now if you are talking about _Name_ then it is a way to make difference between standard(or predefined) macros with user defined.For example GCC predefined macros like __WCHAR_TYPE__ and __WINT_TYPE_ having underscore before and after.

Upvotes: 1

Related Questions