Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

C compilation error "called object is not a function or function pointer"

I got a snippet of C code from online, and I am trying to compile it. I am getting the following error.

error: expected declaration specifiers or '...' before ')' token
    6 | extern FUNC(void, MY_CODE) MyLatestUpdate()(void);
      |                          ^
ERROR!
/tmp/RkrMFH0deT.c: In function 'main':
/tmp/RkrMFH0deT.c:11:41: error: called object is not a function or function pointer
   11 | #define STD_ON                          1u
      |                                         ^~

Below is the snippet of the code

In .h file

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

#define MY_CODE

extern FUNC(void, MY_CODE) MyLatestUpdate()(void);

In another .h file

#define MyLatestUpdate()    MyPreValue()
#define MyPreValue()        UPDATE_VALUE
#define UPDATE_VALUE        STD_ON
#define STD_ON              1u

in .c file

int main() {
    // Write C code here
    MyLatestUpdate()();
    printf("test code");
    return 0;
}

Seems like I am getting the error in the .h file

extern FUNC(void, MY_CODE) MyLatestUpdate()(void);

error: expected declaration specifiers or '...' before ')' token

Is the function declared as a function pointer or a function macro? How can I resolve these issues? Any help

>Solution :

MyLatestUpdate is turned into 1u by the preprocessor. You try to compile

extern FUNC (void, ) 1u()(void);

Which is complete nonsense.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading