[fixed]Compiling on Mac. Error on forward declarations.

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
dreamwalker
Posts: 6
Joined: Tue Sep 08, 2009 10:05 am
Location: Philippines

[fixed]Compiling on Mac. Error on forward declarations.

Post by dreamwalker »

On "CIrrDeviceMacOSX.h"

Code: Select all

class NSWindow;
class NSOpenGLContext;
class NSBitmapImageRep;
Gives out these errors

Code: Select all

Redefinition of 'NSWindow' as a different kind of symbol
Redefinition of 'NSOpenGLContext' as a different kind of symbol
Redefinition of 'NSBitmapImageRep' as a different kind of symbol
Im on Mac 64bit using XCode 4.2 and Mac OS SDK 10.7.

I have tried using macros __cplusplus, removing the forward declarations and/or changing class to @class but it didn't fix the problem.

Has someone gone through this problem and fixed it. Please advise.
I dream therefore I am.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Compiling on Mac. Error on forward declarations.

Post by hybrid »

Are you using the current stable version, or a more recent SVN/trunk version? Because we fixed a lot of errors with newer OSX versions for the upcoming Irrlicht 1.8. Irrlicht 1.7.3 will probably not compile under OSX 10.7
dreamwalker
Posts: 6
Joined: Tue Sep 08, 2009 10:05 am
Location: Philippines

Re: Compiling on Mac. Error on forward declarations.

Post by dreamwalker »

Im using Irrlicht 1.7.2. I'll wait for Irrlicht 1.8 or grab from svn.
I dream therefore I am.
dreamwalker
Posts: 6
Joined: Tue Sep 08, 2009 10:05 am
Location: Philippines

Re: Compiling on Mac. Error on forward declarations.

Post by dreamwalker »

Fixed it.

Solution:
I changed my compiler to LLVM GCC 4.2 from Apple LLVM Compiler 3.0.

It seems that there are issues with mixing C++ and Objective-C in Apple LLVM Compiler 3.0.
Irrlicht 1.7.2 is compatible with Mac if you use GCC compiler and not the faulty Apple compiler.
I dream therefore I am.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: Compiling on Mac. Error on forward declarations.

Post by Nadro »

If You use 10.7 or 10.6 SDK, You should also use Irrlicht from SVN, because 1.7.x have a problems with MacOS X Lion (eg. fullscreen doesn't work on my MacBook with NVIDIA GFX with 10.7 SDK). Switch to a GCC only fix compile issues, but it doesn't solve deprecated methods problems, which are removed from SVN version.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
dreamwalker
Posts: 6
Joined: Tue Sep 08, 2009 10:05 am
Location: Philippines

Re: Compiling on Mac. Error on forward declarations.

Post by dreamwalker »

Thanks for the heads up Nadro. I appreciate it. Cheers to Irrlicht and Mac.
I dream therefore I am.
All8Up
Posts: 16
Joined: Mon Mar 12, 2012 12:42 am

Re: Compiling on Mac. Error on forward declarations.

Post by All8Up »

As a note, I wanted to get Irr compiling using the latest Os X sdk and also using Clang instead of Gcc since all my other code is working under that setup. After running into the issue with the class redefinitions, I poked into the problem and found a quick and simple solution. Wrap the class references as follows:

#ifndef __OBJC__
class NSWindow;
class NSOpenGLContext;
class NSBitmapImageRep;
#endif

All the C++ code see's the opaque pointers as intended and the ObjC code uses the proper definitions from foundation and appkit. Other than a couple of the demo's failing clean shutdown, everything works like a charm.
riham
Posts: 1
Joined: Thu Nov 27, 2014 5:58 am

Re: [fixed]Compiling on Mac. Error on forward declarations.

Post by riham »

BTW, these bugs are present in all three versions: 1.7, 1.8 and trunk.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: [fixed]Compiling on Mac. Error on forward declarations.

Post by Nadro »

This bug will not exist any more after merge ogl-es with trunk, where we have reworked window manager.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
Post Reply