I want to convert a string with / or . into an auto-generated variable name. So I need convert / or . into something acceptable by variable naming, such as __.
It's easy to do it with a function. But with macro, is it possible?
#define ROUTE(path, impl) \
char * k##path##_route = "{"#path":\""#impl"\"}"; // compilation failure for path like /usr/abc or ./abc
I can use impl to name the variable, but since multiple paths may map to the same impl, the compiler will complain about duplication for different paths with the same impl.