LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to extract arguments from a macro function call

Solved!
Go to solution

Hi All,

 

I need help related to Macros in C.

 

This is my code:

 

#ifndef checkTrace
#define checkTrace(fCall)      if(1){printf("function called from checkTrace is:");}
#endif

what i am looking for is :

 

suppose if am calling checkTrace(getchar()); i want to print "getchar() is called from checkTrace macro".

Like this whatever the func called by checkTrace macro, i want to print the message like above mentioning the func called by checkTrace()

 

Please any body let me know how i can do this in CVI?

 

Any help will be greatly appreciated.

 

Thanks,

Harika

0 Kudos
Message 1 of 2
(2,999 Views)
Solution
Accepted by topic author haari

I think what you need is the "stringification operator" : #

 

Check this:

 

#define checkTrace(fCall) if(1){printf("function called from checkTrace is: '%s'", #fCall);}


checkTrace(getchar())


S. Eren BALCI
IMESTEK
0 Kudos
Message 2 of 2
(2,990 Views)