Menu

Variadic macros

pmisik
2017-10-22
2017-10-25
  • pmisik

    pmisik - 2017-10-22

    Hi,
    we have encountered
    (error) Invalid number of character '(' when no macros are defined.

    on following simplified repro code

    #define DEFINE_API_FUNCTION(_type, _name, ...) \
            _type _name ##(__VA_ARGS__)
    
    DEFINE_API_FUNCTION(int, myFunction, const char* arg1, size_t arg2)
    {
       return 0;
    }
    
     
  • Daniel Marjamäki

    Because the code is wrong. Remove ##. you are telling the preprocessor to combine _name and ( into 1 token.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.