GithubHelp home page GithubHelp logo

Comments (10)

alvin777 avatar alvin777 commented on May 14, 2024

I also run into this issue. To analyse it I run Product -> Generate Output -> Preprocessed File to get a preprocessor output (gcc/clang -E option). Quick glance revealed that cocos2dx uthash.h includes <inttypes.h> in the cocos2d namespace which ruins stdint.h inclusion. _UINT8_T macro is set, but uint8_t type is defined in cocos2d namespace and not in global.

I dirtyfixed it by moving #include <inttypes.h> line in uthash.h to the beginning of the file.

from cocos2d-x.

Klaim avatar Klaim commented on May 14, 2024

Works for me too, but I guess it needs to be checked on other platforms than IOS

from cocos2d-x.

kagakuninja avatar kagakuninja commented on May 14, 2024

We can use macros to make the static_casts only happen for C++11, if people are worried about other platforms. Can we get this done?

from cocos2d-x.

 avatar commented on May 14, 2024

Could you not just set all those -1s to UINT32_MAX? That might be faster and we wouldn't need to care about the platform.

from cocos2d-x.

stnguyen avatar stnguyen commented on May 14, 2024

This works for me with XCode 4.4, cocos2d-x 2.0:

  1. Select your Target > Build Settings > All
  2. Find C++ Language Dialect, select C++11 [-std=c++11]
  3. Find C++ Standard Library, select libc++ (LLVM C++ standard library with C++11 support)

from cocos2d-x.

kagakuninja avatar kagakuninja commented on May 14, 2024

Just a warning, if you compile with -std=c++11, then your app will require iOS version 5 or above. I use -std=gnu++11. I had to fix some errors due to bad casts.

from cocos2d-x.

donaldalanmorrison avatar donaldalanmorrison commented on May 14, 2024

This issue can be closed as "not a cocos2d-x issue" or "as designed".

XCode 4.5 does not fully support c++11:

http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_4_5.html#//apple_ref/doc/uid/TP40012559-SW1

@minggo @dumganhar @walzer :-)

from cocos2d-x.

Ryandev avatar Ryandev commented on May 14, 2024

@donaldalanmorrison Nothing in cocos2dx uses anything new in the c++11 standard. So it should still compile against it.

For myself the errors occurring where:
'Unknown type name 'class'; did you mean 'Class'?'

This issue is to do with Xcode->Build Settings->Compile Sources As="According to File Type"

When compiling cocos2dx there is a mix of objective-c & c++. Xcode does struggle to differentiate between the two types. The solution is to wrap each header in a ifdef for that platform. If compiling CCSprite.h wrap the header in:
#ifdef __cplusplus
CCSPRITE HEADER
#endif /* __cplusplus */

the same too for any objective-c files (OBJC)

After the above, Xcode no longer confuses objc with c++ & the cocos2dx source compiles against c++11.

An easy win that won't cause any complications on other platforms I believe.

As for why to bother doing it: I'm new to C++ & using the latest standard does help make things easier.

Cheers,
Ryan

from cocos2d-x.

godyZ avatar godyZ commented on May 14, 2024

@Klaim Please, could you open a bug in redmine in future? We are in process of migrating all the issues to redmine and github issue won't be available after August.

from cocos2d-x.

Klaim avatar Klaim commented on May 14, 2024

@godyZ Noted!

from cocos2d-x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.