Error compiling TKService with Coca on Apple with GCC

Hi,

There is a compilation error related to the Cocoa API when compiling TKService with GCC. In particular, when compiling the file Cocoa/Cocoa_LocalPool.mm. The build instruction is

cd /PATH_TO_OCCT/out/build/src/TKService && /opt/homebrew/bin/aarch64-apple-darwin23-g++-14 -DHAVE_FREETYPE -DHAVE_OPENGL_EXT -DOCC_CONVERT_SIGNALS -I/opt/homebrew/include/freetype2 -I/PATH_TO_OCCT/out/build/include/opencascade -fexceptions -fPIC -Wall -Wextra -O3 -DNDEBUG -s -std=gnu++11 -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -DOCCT_NO_PLUGINS -MD -MT src/TKService/CMakeFiles/TKService.dir/__/Cocoa/Cocoa_LocalPool.mm.o -MF CMakeFiles/TKService.dir/__/Cocoa/Cocoa_LocalPool.mm.o.d -o CMakeFiles/TKService.dir/__/Cocoa/Cocoa_LocalPool.mm.o -c /PATH_TO_OCCT/src/Cocoa/Cocoa_LocalPool.mm

and the error

In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/dispatch/dispatch.h:63,
                 from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:20,
                 from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFPropertyList.h:18,
                 from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:76,
                 from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6,
                 from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12,
                 from /PATH_TO_OCCT/src/Cocoa/Cocoa_LocalPool.mm:23:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/os/object.h:222:1: error: expected unqualified-id before 'interface'
  222 | OS_OBJECT_DECL_BASE(object, NSObject);

Can someone help me? I am running on macOS Sonoma 14.5, using GCC 14.1.0 installed through Homebrew.

Everything works smoothly when using Clang or Apple clang.

Thanks!

Pablo

Dmitrii Pasukhin's picture

Hello, looks like that Cocoa was tested on Clang only. GCC is a little unusual to use on MacOS. I will create an issue, but not sure about fix date.

Best regards, Dmitrii.

Pablo Antolin's picture

Understood. Thanks, Dmitrii.

Pablo