[HLSL] How to do AND or OR?

This topic is 2951 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

As in the title. I want some code to be processed only if macro 1 OR macro 2 is defined. I try:
 #ifdef MACRO1 || MACRO2 
but that doesn't work. Any hint?

Share on other sites
Use #if instead, and define those values with a value of 1 (or 0 if you want them to be disabled). If the macro isn't defined, it will come through as a value of 0.

Share on other sites
So you suggest something like:
 #if defined(MACRO1) | defined(MACRO2) 
? Is | allowed here?

Share on other sites
You want
#if (defined(MACRO1) || defined(MACRO2)) && defined(MACRO3) ... #endif

Share on other sites
Yup, that works. Thanks!

• Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 16
• 30
• 9
• 16
• 22