'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 1:[1]

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.

Solution 2:[2]

As with all #define directives kkData is simply a token that will be replaced by (*SomeFunc()) before compilation. It is not by any means a function pointer, just a macro used to get a result from SomeFunc() and dereference it, in a single word.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vlad from Moscow
Solution 2