Skip to content

Fix "#if with no expression" errors in platform.h#2071

Closed
jmather-sesi wants to merge 1 commit intoAcademySoftwareFoundation:mainfrom
jmather-sesi:platform.h-if-no-expression-fix
Closed

Fix "#if with no expression" errors in platform.h#2071
jmather-sesi wants to merge 1 commit intoAcademySoftwareFoundation:mainfrom
jmather-sesi:platform.h-if-no-expression-fix

Conversation

@jmather-sesi
Copy link
Copy Markdown

Description

When building in debug mode, gcc rasied multiple "#if with no expression" errors with OSL_DEBUG.

Tests

Not applicable. Code compiles.

Checklist:

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable.
  • I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary).
  • My code follows the prevailing code style of this project. If I haven't
    already run clang-format v17 before submitting, I definitely will look at
    the CI test that runs clang-format and fix anything that it highlights as
    being nonconforming.

When building in debug mode, gcc rasied multiple "#if with no
expression" errors with OSL_DEBUG.

Signed-off-by: jmather-sesi <[email protected]>
@linux-foundation-easycla
Copy link
Copy Markdown

CLA Not Signed

@lgritz
Copy link
Copy Markdown
Collaborator

lgritz commented Feb 6, 2026

I'm not sure why this is needed. The first mention of OSL_DEBUG in platform.h is at line 289:

#ifndef OSL_DEBUG
    #ifdef NDEBUG
        #define OSL_DEBUG 0
    #else
        #ifdef _DEBUG
            #define OSL_DEBUG _DEBUG
        #else
            #define OSL_DEBUG 1
        #endif
    #endif
#endif // OSL_DEBUG

That sure looks like it will always result in OSL_DEBUG being defined.

Additionally, in light of this, it's clear that "#ifdef OSL_DEBUG" is the wrong test, since sometimes it is defined and 0.

I feel like something else must be going on. What about that suspicious clause of #define OSL_DEBUG _DEBUG? Is it possible that _DEBUG is defined, but is empty?

@lgritz
Copy link
Copy Markdown
Collaborator

lgritz commented Feb 13, 2026

@jmather-sesi Any thoughts on my question?

@lgritz
Copy link
Copy Markdown
Collaborator

lgritz commented Mar 1, 2026

Hi, @jmather-sesi, checking in again. Please read my earlier comments, I would like your thoughts.

@lgritz
Copy link
Copy Markdown
Collaborator

lgritz commented Apr 2, 2026

@jmather-sesi Checking in again. Can you explain more what's going on here?

@jmather-sesi
Copy link
Copy Markdown
Author

Hi @lgritz, apologies for my tardiness.

I'm not entirely sure how this issue occurred at the time, as I'm unable to reproduce it. I'll re-open if I run into it again.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants