Skip to content

Check if TARGET_OS_OSX is defined before evaluating its value - #9498

Open
nilFinx wants to merge 1 commit into
ocornut:masterfrom
nilFinx:patch-1
Open

Check if TARGET_OS_OSX is defined before evaluating its value#9498
nilFinx wants to merge 1 commit into
ocornut:masterfrom
nilFinx:patch-1

Conversation

@nilFinx

@nilFinx nilFinx commented Aug 4, 2026

Copy link
Copy Markdown

Solves a case where APPLE is defined, but TARGET_OS_OSX isn't, causing a compile error. Happens on my OS X 10.9 setup with MacPorts Clang 16 instead of the Xcode Clang 6.

Compile log before fix:

error: 'TARGET_OS_OSX' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
#elif defined(__APPLE__) && TARGET_OS_OSX && defined(IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS)
                            ^
1 error generated.
image

Solves a case where __APPLE__ is defined, but TARGET_OS_OSX isn't, causing a compile error. Happens on my OS X 10.9 setup with MacPorts Clang 16 instead of the Xcode Clang 6.
@ocornut

ocornut commented Aug 4, 2026

Copy link
Copy Markdown
Owner

How could it be undefined at the top of imgui.cpp has:

// [Apple] OS specific includes
#if defined(__APPLE__)
#include <TargetConditionals.h>
#endif

Can you clarify?

I am not confident having random tests without validating the root cause.
By the logic of your PR, there are 27 other uses of TARGET_OS_OSX in other code and they should all be modified.

Could you investigate why MacPorts Clang 16 doesn't have those inside TargetConditionals.h ?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants