现状:12.2014; HXCPP-VER: 〜.
3.1.39git相关性:
hxcpp
使用名为的主类创建一个新的Haxe项目HxModule.
class HxModule
{
public static function main()
{
Sys.println('Hello from HxModule: "${test()}"');
}
@:headerCode
public static function test():Int
{
return 101;
}
}
Run Code Online (Sandbox Code Playgroud)
build.hxml
-main HxModule
-cp src
-lib hxcpp
# this is for Mac OS X:
-D HXCPP_M64
# this is required on Windows. the "d" stands for debug:
#-D ABI=-MTd
--each
# at this phase we create a binary for tests
-cpp out/cpp/module
--next
# at this phase we create a binary for tests
-cpp out/cpp/module
-D static_link
-D actuate
Run Code Online (Sandbox Code Playgroud)
建立: $ haxe buid.hxml
out/cpp/module/include- 你必须将它修复到完整的路径 ;{your-haxelib-repo}/hxcpp/{version}/include - {here-yours};/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/includeGNU++11 [-std=gnu++11]libstdc++ (GNU C++ standard library)HxModule.aAppDelegate.m- >AppDelegate.mmAppDelegate.mm:#import "AppDelegate.h"
#import "HxModule.h"
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSLog(@"test: %d", ((int)HxModule_obj::test()));
}
@end
Run Code Online (Sandbox Code Playgroud)
此外,对于自动完成和更好的导航,您可以在目录中添加Xcode-project 参考组:
include 来自Haxe的输出;include来自haxelib hxcpp.在撰写本文时,只有一个可能的问题.它可以通过编辑文件来解决{haxelib:hxcpp}/include/hxcpp.h.只需在文件的开头添加几行:
#ifndef HXCPP_H
#define HXCPP_H
// Standard headers ....
// Custom override by @suhinini
#define Class HxcppClass
// Basic mapping from haxe -> c++
typedef int Int;
typedef bool Bool;
// Windows hack
#define NOMINMAX
#ifdef _MSC_VER
#include <typeinfo.h>
namespace hx { typedef ::type_info type_info; }
...
Run Code Online (Sandbox Code Playgroud)
看后// Standard headers .....
示例项目.
| 归档时间: |
|
| 查看次数: |
1392 次 |
| 最近记录: |