I have code that has code like that
#if defined(A) and defined(b)
...
#endif
It fails with a lot of syntax errors which denotes that parsing failed
If I replace and
with &&
it compiles. I don't want to make changes in thirdparty library, is there a way to make it recognize those operators?
CodePudding user response:
You can just
#include <iso646.h>
That header defines alternative tokens for the operators. But it's really not a good way. Just use the normal C operators
CodePudding user response:
Since in C , and
and or
are built-it alternative operator representations, the C version of <iso646.h>
(and <ciso646>
, which was removed in C 20) header file does not define anything. However, Microsoft's extensions to C conflict with those.
You can require strict language conformance by using the /permissive-
switch. (Note that setting the C language standard level to C 20 using the /std:c 20
switch will automatically enable strict conformance as well).
Another way is to use the /Za
switch to disable Microsoft's extensions to C language. (However, Microsoft does not recommend using /Za
when code is compiled as C .)