ARC and bridged cast

I agree that the description is confusing. Since I just grasped them, I’ll try to summarize: (__bridge_transfer <NSType>) op or alternatively CFBridgingRelease(op) is used to consume a retain-count of a CFTypeRef while transferring it over to ARC. This could also be represented by id someObj = (__bridge <NSType>) op; CFRelease(op); (__bridge_retained <CFType>) op or alternatively … Read more

Can I use C++11 with Xcode?

Xcode 4.2 had finally added support for C++0X: In the project build settings screen, switch on “All” options. In the “Build Options” section, set compiler to “Apple LLVM compiler 3.0”. Scroll down to “Apple LLVM Compiler 3.0 – Language” section and set “C++ Language Dialect” to “C++0X” and “C++ Standard Library” to “libc++”. The std::move(), … Read more

Catalina C++: Using headers yield error: no member named ‘signbit’ in the global namespace

I’m curious: What compiler are you using? What’s the value of CMAKE_OSX_SYSROOT? I’m fairly convinced this is the result of a wrong CMAKE_OSX_SYSROOT. I had the problem you’re describing when using python bindings for clang (where CMake doesn’t manage the compiler call), but I managed to recreate the error in CMake by doing: set(CMAKE_OSX_SYSROOT “”) … Read more

Why can’t clang with libc++ in c++0x mode link this boost::program_options example?

You need to rebuild boost using clang++ -stdlib=libc++. libc++ is not binary compatible with gcc’s libstdc++ (except for some low level stuff such as operator new). For example the std::string in gcc’s libstdc++ is refcounted, whereas in libc++ it uses the “short string optimization”. If you were to accidentally mix these two strings in the … Read more

Clang optimization levels

I found this related question. To sum it up, to find out about compiler optimization passes: llvm-as < /dev/null | opt -O3 -disable-output -debug-pass=Arguments As pointed out in Geoff Nixon‘s answer (+1), clang additionally runs some higher level optimizations, which we can retrieve with: echo ‘int;’ | clang -xc -O3 – -o /dev/null -\#\#\# Documentation … Read more

constexpr and initialization of a static const void pointer with reinterpret cast, which compiler is right?

TL;DR clang is correct, this is known gcc bug. You can either use intptr_t instead and cast when you need to use the value or if that is not workable then both gcc and clang support a little documented work-around that should allow your particular use case. Details So clang is correct on this one … Read more

Enable OpenMP support in clang in Mac OS X (sierra & Mojave)

Try using Homebrew’s llvm: brew install llvm You then have all the llvm binaries in /usr/local/opt/llvm/bin. Compile the OpenMP Hello World program. Put omp_hello.c /****************************************************************************** * FILE: omp_hello.c * DESCRIPTION: * OpenMP Example – Hello World – C/C++ Version * In this simple example, the master thread forks a parallel region. * All threads in … Read more