Question

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 '#'?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top