C++ code fails to compile after upgrading XCode 5.0 -> 5.1 “forward declaration of class cannot have a nested name specifier”

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 14:22:46

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/22389784/c-code-fails-to-compile-after-upgrading-xcode-5-0-5-1-forward-declaration

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!