#define PLAINTEXT_TARGET "plaintext"
if( strstr(PLAINTEXT_TARGET, optarg) == PLAINTEXT_TARGET )
/* ... */
Does the C language guarantee that PLAINTEXT_TARGET above compiles into a single instance? If the compiler may produce two instances of the macro string then the conditional above is misleading and can be false.
Macros do simple textual replacement. The preprocessor replaces every occurrence of
PLAINTEXT_TARGETwith"plaintext", after that the compiler looks at the result and compiles that.So the compiler sees two string literals and it’s not guaranteed that those won’t be stored separately (see Alok’s answer for the according quote from the standard). The code is indeed misleading, it would be more reasonable to declare
PLAINTEXT_TARGETas a constant: