PlatformIO Community

Debug macro issue

Hi,

Today i tried to recompile an old code I wrote few months ago and ran into an unexpected error related to the classic debug macro:

#define DEBUG “Test”
#define INFO(x, …) std::printf("[INF %s %3d] “x”\r\n", DEBUG, LINE, ##VA_ARGS);
INFO(“doh %i”,1);

gave me:
unable to find string literal operator 'operator""x' with 'const char [16]', 'unsigned int' arguments

I’m a bit at lost here and any help will be appreciated!

Thanks!

I cannot exactly reproduce your error message. Additional information about your platform, framework etc. would have been helpful.

The main problem is the missing space before the x.

Furthermore, the LINE and VA_ARGS macros are called __LINE__ and __VA_ARGS__ in up-to-date compilers.

The below code compiles in different environments:

#include <stdio.h>

#define DEBUG "Test"
#define INFO(x, ...) printf("[INF %s %3d] " x "\r\n", DEBUG, __LINE__, ##__VA_ARGS__);

int main(void) {
    INFO("doh %i", 1);
}

Thanks. It was the missing spaces between the x…