Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8426187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:28:42+00:00 2026-06-10T04:28:42+00:00

So I want to publicly expose a Box2D (C++) pointer to other Objective-C++ classes

  • 0

So I want to publicly expose a Box2D (C++) pointer to other Objective-C++ classes in my cocos2d + box2d project. I declare a method “getWorld” in my interface which references C++ class b2World and imports Box2D.h. All the files in my project are .mm extension, and I get the following compile error:

In file included from DebugDrawLayer.mm:2:
In file included from World.h:10:
In file included from external/Box2d/Box2D/Box2D.h:34:
external/Box2d/Box2D/Common/b2Settings.h:22:10: fatal error: 'cassert' file not found
#include <cassert>

I guess Box2D.h is somehow compiled as C instead of C++, but I fail to understand how this happens. According to the log the include chain clearly starts from a .mm file.

Update:

The log says for World.mm (compiled earlier) that it clearly compiles as objective-c++

CompileC Objects-normal/i386/World.o World.mm normal i386 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler 

but for DebugDrawLayer.mm it says objective-c

CompileC Objects-normal/i386/DebugDrawLayer.o DebugDrawLayer.mm normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler

Both files are set as default – Objective-C++ source. What gives..?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:28:44+00:00Added an answer on June 10, 2026 at 4:28 am

    This appears to be a MAJOR bug in Xcode4, nothing to do with compiler settings – just Xcode internals.


    UPDATE:

    I eventually found the root cause. Yes, it’s a bug in Xcode/LLVM. It compiles files in the wrong order, and then overrides its own settings, and breaks itself. Apple’s tech support was too incompetent to even understand the problem, so I doubt they’ll be fixing the bug anytime soon.

    (NB: Skip this section, and see below, for my original answer, that gives a BRUTE FORCE but VERY QUICK TO DO solution)

    What happens is … if the compiler “sees” a C++ header while processing a C class … it then marks that header (internally) as “C” (even when this is literally impossible).

    Later on, when it comes back to that header, trying to compile it with C++, it finds it has already told-itself that the header is “C” (because it’s incredibly stupid) … and promptly crashes.

    The correct solution (which requires lots of time and effort) is to go through EVERY C FILE in your project, and check (manually, because Xcode sucks) EVERY reference to EVERY header file — and, for each one, EVERY header file it imports … etc.

    (this can take hours)

    …until you find the chain of imports that leads to a C file “seeing” a C++ header.

    All of this should be automated (but isn’t). And the root problem shouldn’t happen (if Xcode were correctly written).


    I tried everything listed elsewhere on the web, most of the solutions are “keep removing/adding the file, and eventually Xcode will fix itself if you’re lucky”.

    I wasn’t lucky. The only thing that worked was:

    1. Go to build settings for your project
    2. find the “Compile Sources As” setting
    3. set it to “Objective-C++”
    4. re-build

    The actual name/value is: “GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp” – so my guess is that this sidesteps Xcode’s (broken!) internal logic.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a personal Git repository which I don't want to have publicly available
If I want to have a publicly accessible function on a jQuery plugin I'm
Let's say I want make some of my sources publicly available via my blog
want to have a Hyperlink-Button in a gridView in which I can display a
Want to be able to provide a search interface for a collection of objects
I'm writing a Ruby class, and want to override the == method. I want
Suppose the following Employee class (yes I know I shouldn't publicly expose Lists but
I have a directory on a linux box that I want to make publicly
I want to write a static utility class which only has a set of
I want to control the creation of a bunch of classes that all share

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.