Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何转换C++;在Xcode中以C为目标编译Box2D? 尝试使用Box 2D作为iPhone应用程序,但不知道如何将下面的C++头文件转换成XCODE Objor C。有人能帮我吗?提前谢谢你 #include <Box2D/Common/b2Settings.h> #include <cstdlib> #include <cstdio> #include <cstdarg> b2Version b2_version = {2, 2, 1}; // Memory allocators. Modify these to use your own allocator. void* b2Alloc(int32 size){ return malloc(size); } void b2Free(void* mem) { free(mem); } // You can modify this to use your logging facility. void b2Log(const char* string, ...) { va_list args; va_start(args, string); vprintf(string, args); va_end(args); } #包括 #包括 #包括 #包括 b2Version b2_version={2,2,1}; //内存分配器。修改它们以使用您自己的分配器。 void*b2Alloc(int32大小){ 返回malloc(大小); } 无效b2Free(无效*内存) { 免费(mem); } //您可以对此进行修改以使用日志记录功能。 无效b2Log(常量字符*字符串,…) { va_列表参数; va_开始(参数、字符串); vprintf(字符串,参数); va_端(args); }_C++_Objective C_Header Files_Box2d Iphone - Fatal编程技术网

如何转换C++;在Xcode中以C为目标编译Box2D? 尝试使用Box 2D作为iPhone应用程序,但不知道如何将下面的C++头文件转换成XCODE Objor C。有人能帮我吗?提前谢谢你 #include <Box2D/Common/b2Settings.h> #include <cstdlib> #include <cstdio> #include <cstdarg> b2Version b2_version = {2, 2, 1}; // Memory allocators. Modify these to use your own allocator. void* b2Alloc(int32 size){ return malloc(size); } void b2Free(void* mem) { free(mem); } // You can modify this to use your logging facility. void b2Log(const char* string, ...) { va_list args; va_start(args, string); vprintf(string, args); va_end(args); } #包括 #包括 #包括 #包括 b2Version b2_version={2,2,1}; //内存分配器。修改它们以使用您自己的分配器。 void*b2Alloc(int32大小){ 返回malloc(大小); } 无效b2Free(无效*内存) { 免费(mem); } //您可以对此进行修改以使用日志记录功能。 无效b2Log(常量字符*字符串,…) { va_列表参数; va_开始(参数、字符串); vprintf(字符串,参数); va_端(args); }

如何转换C++;在Xcode中以C为目标编译Box2D? 尝试使用Box 2D作为iPhone应用程序,但不知道如何将下面的C++头文件转换成XCODE Objor C。有人能帮我吗?提前谢谢你 #include <Box2D/Common/b2Settings.h> #include <cstdlib> #include <cstdio> #include <cstdarg> b2Version b2_version = {2, 2, 1}; // Memory allocators. Modify these to use your own allocator. void* b2Alloc(int32 size){ return malloc(size); } void b2Free(void* mem) { free(mem); } // You can modify this to use your logging facility. void b2Log(const char* string, ...) { va_list args; va_start(args, string); vprintf(string, args); va_end(args); } #包括 #包括 #包括 #包括 b2Version b2_version={2,2,1}; //内存分配器。修改它们以使用您自己的分配器。 void*b2Alloc(int32大小){ 返回malloc(大小); } 无效b2Free(无效*内存) { 免费(mem); } //您可以对此进行修改以使用日志记录功能。 无效b2Log(常量字符*字符串,…) { va_列表参数; va_开始(参数、字符串); vprintf(字符串,参数); va_端(args); },c++,objective-c,header-files,box2d-iphone,C++,Objective C,Header Files,Box2d Iphone,您是否尝试过Objective-C++模式?将.m/.cpp文件重命名为.mm是否尝试了Objective-C++模式?将您的 .m>代码> >代码> > CP> 文件>代码> .mm < /Code > < P>。除了标题,所有代码都是C,而不是C++。例如,malloc/free是C例程。C++中的最近例程是新< /COD> >代码>删除< /代码> .< 除非您没有向我们展示其他代码,否则您应该能够简单而安全地指向C头,而不是: #include <stdlib.h> /*

您是否尝试过Objective-C++模式?将
.m
/
.cpp
文件重命名为
.mm

是否尝试了Objective-C++模式?将您的<代码> .m>代码> >代码> > CP> <代码>文件>代码> .mm < /Code >

< P>。除了标题,所有代码都是C,而不是C++。例如,
malloc
/
free
是C例程。C++中的最近例程是<代码>新< /COD> >代码>删除< /代码> .< 除非您没有向我们展示其他代码,否则您应该能够简单而安全地指向C头,而不是:

#include <stdlib.h>   /* was #include <cstdlib> */
#include <stdio.h>    /* was #include <cstdio>  */
#include <stdarg.h>   /* was #include <cstdarg> */
#include/*was#include*/
#包括/*是#包括*/
#包括/*是#包括*/

……代码块应该编译成C(因此在Objy-C项目中)。

< P>除了头文件之外,所有代码都是C,而不是C++。例如,
malloc
/
free
是C例程。C++中的最近例程是<代码>新< /COD> >代码>删除< /代码> .< 除非您没有向我们展示其他代码,否则您应该能够简单而安全地指向C头,而不是:

#include <stdlib.h>   /* was #include <cstdlib> */
#include <stdio.h>    /* was #include <cstdio>  */
#include <stdarg.h>   /* was #include <cstdarg> */
#include/*was#include*/
#包括/*是#包括*/
#包括/*是#包括*/
…这段代码应该编译为C(因此在Objective-C项目中)