Skip to content

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

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

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

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 <54645798+jmather-sesi@users.noreply.github.com>
@linux-foundation-easycla
Copy link

CLA Not Signed

@lgritz
Copy link
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
Collaborator

lgritz commented Feb 13, 2026

@jmather-sesi Any thoughts on my question?

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