我正在尝试使用Haxe中的Windows API来创建Windows应用程序。我已经使用ndlls和Haxe/Neko做到了这一点。我尝试在cpp目标中使用Haxe2.09中的新宏特性将C++代码嵌入到Haxe文件中。但是,一旦我包含windows.h,它就会给出一个错误
./src/Main.cpp(79) : error C2039: 'RegisterClassA' : is not a member of 'hx'
./src/Main.cpp(81) : error C2660: 'RegisterClassA' : function does not take 9 arguments
Called from ? line 1
Called from BuildTool.hx line 1246
Called from BuildTool.hx line 554
Called from BuildTool.hx line 591
Called from BuildTool.hx line 710
Called from BuildTool.hx line 785
Uncaught exception - Error in building thread
Error : Build failed
Build halted with errors (haxe.exe).这是我的代码-
import cpp.Lib;
@:headerCode("#include <windows.h>")// if i comment this line or replace windows.h with another standard header file like iostream, the error goes
class Main
{
static function main()
{
//no code here
}
}事实上,如果我用Windows或DirectX SDK中的任何头文件替换windows.h,我在使用Haxe2.09和FlashDevelop时都会得到相同的错误。我使用的是Windows7。我也使用最新版本的hxcpp (2.09版)。
发布于 2012-04-16 11:03:14
看起来<windows.h>是#defining RegisterClass to RegisterClassA (自动魔术Unicode支持的一部分)。
因为这是通过文本预处理器宏完成的,所以任何具有名为RegisterClass的符号(就像BuildTool的情况一样)的代码都会自动将其替换为RegisterClassA,这显然会导致问题,如果有人以适当的名称查找函数。
试试这个:
@:headerCode("#include <windows.h>")
@:headerCode("#undef RegisterClass")对于其他碰撞,您可能需要执行类似的操作。另请参见this question。
https://stackoverflow.com/questions/10168193
复制相似问题