cocos2d-x的Android工程开启c++0x特性

首先一定要确定你所安装NDK支持c++0x(我安装的android-ndk-r8)

文本打开 项目目录/proj.android/jni/Application.mk

在APP_CPPFLAGS那一行最后追加上 -std=c++0x,改完之后可能这样

APP_CPPFLAGS := -FRTTI -DCOCOS2D_DEBUG=1 -std=c++0x

 

ok,在代码里测试下

把一下代码加入工程中试试

//test.cpp
#include <functional>
 
void Test()
{
   //1
   int r = 0; 
   std::function<int(void)>Foo = [&](){ return ++r; }  
   int res = Foo();
 
   //2
   int arr[20];
   for(int i:arr)
  {
  }
 
   //3
   auto b = arr;
   b[0] = 20;

   //4
   auto pF = [](int x)->int{ return x; };  
}

  

这个步骤可选,目的是用g++4.7当做交叉编译工具

NDK_TOOLCHAIN_VERSION := 4.7

如果你加上了这个

你可以这样写类

1 class A
2 {
3   int a = 0;
4 }

 

  

 

posted @ 2013-06-17 14:06  MrBlue  阅读(507)  评论(0编辑  收藏  举报