Will present the question first, then the reasoning behind it.
Question: Can I ask if a substring is part of a string at compile time? i.e. Can I use preprocessor logic to ask whether "Subst" is part of the string "Text1 Subst Text2..."?
Reasoning: I work on this large C code base, which has a given tracing framework. This framework allows turning on traces based on trace levels - error, warning, info, debug. This is enabled at compile time, meaning that the strings in the debug traces won't even get compiled if trace level doesn't include the debug level. So far nothing new.
Now, in addition, this framework requires modules to specify their trace group as a string.
e.g. #define TRACE_GROUP "GRP1".
Trace group is displayed in traces and allows filtering traces according to groups - but in run time. This is done using simple C substring functions.
What I'm asking is whether there's a way to do it in compile time. i.e. ask if a trace group is part of a set (like "Grp1 Grp3 Grp7") using preprocessor directives. Reason I need it is the fact that the system is limited in code size. Turning on trace level will fill it with undesirable strings from all modules, while all I want to include is strings from specific modules.
Didn't see any apparent way to accomplish that, maybe I'm wrong.