Namespaces
Variants
Views
Actions

Talk:cpp/preprocessor/conditional

From cppreference.com

Looking at the C++ standard, it seems that there is an operator "defined" that can be used in preprocessor conditionals that is not mentioned here. It is defined in 16.1.1

it's right on this page where it says "If the expression contains unary operators in form defined identifier or defined (identifier)". Could be formatted better, pehaps. --Cubbi (talk) 14:26, 5 December 2016 (PST)

[edit] What happens when the expression in #if has 'undefined behavior'?

What is the outcome of an condition that contains undefined behavior?

For example, in C++ shift operators have some undefined behavior. If i use these cases in the preprocessor, what should be the result? Is a diagnosis message then required?

#if (-1 << -1) > 0
...
#endif

Thanks, Heiko Eißfeldt 88.70.0.237 15:53, 18 September 2017 (PDT)

If the expression contains undefined behavior, then it cannot be a constant expression, thus a diagnostic message is required. --D41D8CD98F (talk) 08:47, 19 September 2017 (PDT)