juce_Expression.cpp: Compile errors in Xcode 4.3

In file included from …/…/…/JUCE/modules/juce_core/juce_core.cpp:108:
…/…/…/JUCE/modules/juce_core/maths/juce_Expression.cpp:47:16: error: no viable conversion from ‘std::__1::nullptr_t’ to 'ReferenceCountedObjectPtrjuce::Expression::Term
return nullptr;

This is the latest tip


There’s nothing wrong with that code, and it compiles just fine for me, in XCode 4.3… No idea what you might have done that would break it. Are you building with gcc or clang?

Hmm…I had it on Apple LLVM Compiler and that generated the errors. I switched over to LLVM GCC and the error went away.

Odd. I use llvm all the time, and have no problems at all with it.

When you say you use LLVM, what does that mean exactly? Because both compiler choices say “LLVM”

I mean the clang one, I think they call it LLVM 3.1

Well yep, compile error with LLVM 3.1, success with LLVM GCC 4.2


Rumor has it that Apple LLVM 3.1 is the preferred compiler…

It’s certainly my preferred compiler. Don’t know what settings you must have enabled to make it fail on such an innocent line of code though.

Are you using Apple LLVM 3.1? Try making a fresh xcode static library project from scratch (without IntroJucer) and add the module containing juce_Expression.cpp and you will see this error.

Interesting side note, changing all occurences of:

const TermPtr newDest (createDestinationTerm (scope, input, overallTarget, topLevelTerm));
if (newDest == nullptr)
  return nullptr;


const TermPtr newDest (createDestinationTerm (scope, input, overallTarget, topLevelTerm));
if (newDest == nullptr)
  return newDest;

fixes most compile errors. There are a few more that should be changed to “return TermPtr()” and “return ReferenceCountedObjectPtr()” instead of “return nullptr” but not many before all errors are fixed. I am not sure why this is needed but Xcode / the default compiler for MacOS, Apple LLVM compiler 3.1 insists.


I think I see what’s going on here. Your xcodeproj is either old, or generated by Introjucer. Since then, Apple has added some new configuration options in the Build settings. For example, the JUCE xcodeproj files don’t have “Automatic Reference Counting” set at all on the Project (inheriting the Mac OS Default of “No”). A new xcodeproj created in Xcode will have this set to “No” on the Project target.

Try using XCode to create a new project file, and add juce_core.cpp to it and you will get this error.

Compiler “LLVM GCC 4.2” (default with Xcode 4.3, Mac OS targets), “C++ Language Dialect”: “C++11” and “C++ Standard Library”: “libc++ (LLVM C++ standard library with C++11 support)” fixes the compile errors without the need for any changes to the code.