Frage

Is there a way to use a preprocessor directive without using the # character in C code? Can we echo the hash character somehow by using its ASCII etc. equivalents?

Eg: 1 can be echoed by using 'SOH' in the .c source file. Is there a similar hack for '#'?

War es hilfreich?

Lösung

You can use the digraph or trigraph equivalent if your compiler supports them (you may need to pass flags to the compiler):

digraph: %:

trigraph: ??=

However, if you're trying to use preprocessor macros to generate preprocessor commands, there's no way to do that.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top