Convert a preprocessor token to a string

see http://www.decompile.com/cpp/faq/file_and_line_error_string.htm
specifically:

#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define AT __FILE__ ":" TOSTRING(__LINE__)

so your problem can be solved by doing
sscanf(buf, "%" TOSTRING(MAX_LEN) "s", val);

Leave a Comment