[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Variadic macro in definition of fail_msg


Hi,

since the bug tracker seems to be down, I'll report this here.

The fail_msg macro is defined as follows (in cmocka.h):

#define fail_msg(msg, ...) do { \
    print_error("ERROR: " msg "\n", ##__VA_ARGS__); \
    fail(); \
} while (0)


I believe that the '##' token pasting operator is unnecessary, and it causes a warning in my compiler (IAR for ARM):

  Warning[Pe1665]: concatenation with "REDACTED" in macro "fail_msg" does not create a valid token

The following code works fine for me, but I have not tested it on other compilers:

#define fail_msg(msg, ...) do { \
    print_error("ERROR: " msg "\n", __VA_ARGS__); \
    fail(); \
} while (0)


Best regards,
Stephan Walter



Follow-Ups:
Re: Variadic macro in definition of fail_msgLukas Slebodnik <lslebodn@xxxxxxxxxx>