By finding-c++-static-initialization-order-problems, I want to define a macro in a header file, e.g. "check_fiasco.h", then put this header file to the top of every cpp file, as Warren Stevens' idea. However, I tried his code under linux, and it does not work(it compiles, but crashes when it gets executed).
I tried the following macro:
#define TOKENCONCAT(x, y) x ## y
#define file_init_(x, y) TOKENCONCAT(x, y)
#define FIASCO_FINDER_DEC \
void file_init_(file_, __FILE__)(void) ((constructor)) ;
#define FIASCO_FINDER_IMPL \
void file_init_(file_, __FILE__)(void) __attribute__ {\
printf("Good Morning, %s!\n", __FILE__);\
return ;\
}
However, this does not work, as the pasting file name with "/" is not allowed for function name. I cannot use __COUNTER__
either, as the declaration and implementation has to be the same.
Any ideas?