Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
January 23, 2014 Symbol Undefined _EnumWindows@12 | ||||
---|---|---|---|---|
| ||||
hello. having trouble importing WinAPI function EnumWindows. example: //****************************************** module main; pragma(lib, "user32"); alias int function (void*, long) WNDENUMPROC; extern (Windows) int EnumWindows(WNDENUMPROC, long); //extern (Windows) void* CreateToolhelp32Snapshot(int, int); int main(string[] args) { //auto hSnapshot = CreateToolhelp32Snapshot(0x2, 0); EnumWindows( &EnumWindowsProc, 0 ); return 0; } int EnumWindowsProc(void* hwnd, long lParam) { return 1; } / / ****************************************** have when compiling error: Symbol Undefined _EnumWindows@12 other WinAPI functions imported successfully. the reason for the error? |
January 23, 2014 Re: Symbol Undefined _EnumWindows@12 | ||||
---|---|---|---|---|
| ||||
Posted in reply to AntonSotov | "AntonSotov" wrote in message news:qyxvsktbxokfhwebgwdk@forum.dlang.org... > extern (Windows) int EnumWindows(WNDENUMPROC, long); The second argument is LPARAM, which maps to C's long, but D's long maps to C's long long. To be safe, use these aliases whenever possible by using: import core.sys.windows.windows; |
January 23, 2014 Re: Symbol Undefined _EnumWindows@12 | ||||
---|---|---|---|---|
| ||||
Posted in reply to AntonSotov | On Thursday, 23 January 2014 at 17:22:55 UTC, AntonSotov wrote:
> alias int function (void*, long) WNDENUMPROC;
> extern (Windows) int EnumWindows(WNDENUMPROC, long);
These shouldn't be longs. You could call them LPARAM (import core.sys.windows.windows) or int.
A "long" in C is actually an "int" in D. D's "long" is more like C's "long long".
|
January 23, 2014 Re: Symbol Undefined _EnumWindows@12 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On 2014-01-23 18:27, Adam D. Ruppe wrote: > These shouldn't be longs. You could call them LPARAM (import > core.sys.windows.windows) or int. > > A "long" in C is actually an "int" in D. D's "long" is more like C's > "long long". A "long" in C is actually a D "int" on Windows. On Posix it's a D "int" when compiling for 32bit and a D "long" when compiling for 64bit. This is a simplification that holds for the most common platforms available today. For more details see: http://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models -- /Jacob Carlborg |
January 24, 2014 Re: Symbol Undefined _EnumWindows@12 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | all thank you very much! realized my mistake. |
Copyright © 1999-2021 by the D Language Foundation