[Solved]Where does Qt define the __VA_ARGS__ macro ?

  • Hi, I want to define a variadic macro like:
    @#define LOG(fmt, ...) printf(fmt, ##VA_ARGS)@

    Both "##" and "VA_ARGS"can not pass the compiler. Does Qt support the variadic macro? If so, which header I should include?



  • Moderators

    Your compiler needs to support variadic macros. Qt can not make them work for you.

  • Tobias, you are right. The compiler, i.e. gcc, comes with the platform, not with the Qt. Thank you very much.

    I am using Mac OS X. I tried <stdio.h> and <stdarg.h>, no luck yet. Any one can tell me which header defines this "VA_ARGS" macro?



  • It turns out that I mistakenly try to use this "VA_ARGS" in a function directly.
    I examined that both of the following format work in Qt program:
    @#define LOG(fmt, ...) dbg_func(fmt, ##VA_ARGS)
    #define LOG(fmt, args...) dbg_func(fmt, ##args)@

    Sorry for the annoying.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.