0

Haxe で Windows API を使用して Windows アプリケーションを作成しようとしています。ndlls と Haxe/Neko を使用して既にこれを行っています。Haxe 2.09 の新しいマクロ機能を使用して、C++ コードを Haxe ファイルに埋め込む cpp ターゲットで試してみました。しかし、含めるとすぐに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.hWindows または DirectX SDK のヘッダー ファイルに置き換えると、Haxe 2.09 と FlashDevelop を使用した場合と同じエラーが発生します。Windows 7 を使用しています。最新バージョンの hxcpp (バージョン 2.09) も使用しています。

4

1 に答える 1

2

<windows.h>#defining RegisterClassto RegisterClassA(auto-magic Unicode サポートの一部) のように見えます。

これは text-preproccessor マクロで行われるため、RegisterClass(BuildTool の場合のように) という名前のシンボルを持つすべてのコードは、自動的に にスワップ アウトされますRegisterClassA。これは、誰かが適切な名前で関数を探しに行くと、明らかに問題を引き起こします。 .

これを試して:

@:headerCode("#include <windows.h>")
@:headerCode("#undef RegisterClass")

他のクラッシュでも同様の操作が必要になる場合があります。この質問も参照してください。

于 2012-04-16T03:03:14.360 に答える