To the best of my knowledge, there are no preprocessor directives for detecting strict aliasing.
If you are using gcc's "-Wall" then the compiler will warn you about code that may break the strict aliasing rule.
-Wstrict-aliasing
--- This option is only active when ‘-fstrict-aliasing’ is
active. It warns about code which
might break the strict aliasing rules
that the compiler is using for
optimization. The warning does not
catch all cases, but does attempt to
catch the more common pitfalls. It is
included in ‘-Wall’. It is equivalent
to ‘-Wstrict-aliasing=3’
If the code you are working on is critical then you can disable -fstring-aliasing
in gcc. Or if you don't want to disable strict aliasing, I suggest looking at the asm output to make sure the compiler isn't doing dangerous optimizations that you don't want.
As an aside, akauppi said in the comments:
'restrict' enables strict aliasing
optimizations for particular pointers.
The restrict keyword does not "enable ... optimizations" directly but rather it gives the compiler more information and that extra information indirectly helps the compiler determine if it can apply specific optimization techniques.
A good explanation of the restrict keyword from TI's DSP compiler documentation:
To help the compiler determine memory dependencies, you can qualify a
pointer, reference, or array with the restrict keyword. The restrict keyword is
a type qualifier that may be applied to pointers, references, and arrays. Its use
represents a guarantee by the programmer that within the scope of the pointer
declaration the object pointed to can be accessed only by that pointer. Any
violation of this guarantee renders the program undefined. This practice helps
the compiler optimize certain sections of code because aliasing information
can be more easily determined.