Search code examples
cmacrosreturn-valuefunction-call

How does #define work with function pointers?


Please see the below code :

SomeStructure* SomeFunc();
#define kkData (*SomeFunc())

Question : What does kkData represents ?

EDIT : Removed semi-colon from second line.


Solution

  • This directive

    #define kkData (*SomeFunc());
    

    means a call of the function SomeFunc and dereferencing the pointer to a structure returned from the function.

    For example you could write in the program

    SomeStructure s = kkData
    

    Pay attention to that the semicolon in the directive should be removed. In this case the code in the program

    SomeStructure s = kkData;
    

    will be more clear.