首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Haxe和Windows API

Haxe和Windows API
EN

Stack Overflow用户
提问于 2012-04-16 10:53:47
回答 1查看 1.2K关注 0票数 0

我正在尝试使用Haxe中的Windows API来创建Windows应用程序。我已经使用ndlls和Haxe/Neko做到了这一点。我尝试在cpp目标中使用Haxe2.09中的新宏特性将C++代码嵌入到Haxe文件中。但是,一旦我包含windows.h,它就会给出一个错误

代码语言:javascript
复制
./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).

这是我的代码-

代码语言:javascript
复制
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版)。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-04-16 11:03:14

看起来<windows.h>是#defining RegisterClass to RegisterClassA (自动魔术Unicode支持的一部分)。

因为这是通过文本预处理器宏完成的,所以任何具有名为RegisterClass的符号(就像BuildTool的情况一样)的代码都会自动将其替换为RegisterClassA,这显然会导致问题,如果有人以适当的名称查找函数。

试试这个:

代码语言:javascript
复制
@:headerCode("#include <windows.h>")
@:headerCode("#undef RegisterClass")

对于其他碰撞,您可能需要执行类似的操作。另请参见this question

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10168193

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档