3

I have this in a .h file:

class Ogre::ManualObject;

I don't know how it got there but it's always compiled under multiple compilers - until suddenly XCode5.1 raises it as an error.

Have Apple changed the C++ compiler again?

Mr. Boy
  • 60,845
  • 93
  • 320
  • 589
  • And was this really ever legal C++? – Mr. Boy Mar 13 '14 at 20:09
  • What is the exact error? I am no C++ Standard expert, but the draft version from January 2012 explicitly mentions *forward declarations* as a valid tool. And the XCode 5.1 release notes also provide no other information. – Philip Allgaier Mar 13 '14 at 20:19
  • 2
    The error is in the title. It's specifically because I forward declare a class inside a namespace instead of `namespace Ogre{ class ManualObject; }` – Mr. Boy Mar 14 '14 at 10:46
  • @John Add the fix to an answer, works for me. – Paul Solt Mar 17 '14 at 15:40

2 Answers2

3

As John suggested, change class Ogre::ManualObject; to namespace Ogre{ class ManualObject;}. I had exactly the same problem (but with different declarations), also with Ogre and Xcode 5.1. Changed 3 lines, everything worked.

Maxim Chetrusca
  • 3,262
  • 1
  • 32
  • 28
  • I don't think that would work if you also had `class Ogre;`, e.g.: `class Ogre; namespace Ogre { class ManualObject; };` gives me with clang++-11 `error: redefinition of 'Ogre' as different kind of symbol` – oromoiluig Jul 18 '23 at 15:11
0

Possibly that never was legal. It would depend on the code around it (hard to say just based on that one line without knowing the referencing points). See this SO thread.

Apparently, you are not the only one experiencing this issue after an XCode 5.1 update. See this thread regarding Scaleform (autodesk.com). I however couldn't find anything related in the XCode or LLVM/clang release notes.

Community
  • 1
  • 1
Philip Allgaier
  • 3,505
  • 2
  • 26
  • 53