Migrating code to BlitzmaxNG problems

Started by Ashmoor, June 10, 2020, 23:47:05

Previous topic - Next topic

Ashmoor

I am migrating my code from Blitzmax to BlitzmaxNG and I am getting some errors when compiling:

QuoteIn file included from M:/GameDev/33 Mosaics/game sol BMX NG/.bmx/main.bmx.gui.debug.win32.x86.c:1:
M:/GameDev/33 Mosaics/game sol BMX NG/.bmx/main.bmx.gui.debug.win32.x86.h:1987:25: error: conflicting types for 'GetActiveWindow'
extern BBINT __stdcall  GetActiveWindow();
                         ^~~~~~~~~~~~~~~
In file included from C:/Users/catalin/Desktop/programare/BlitzMaxNG/BlitzMax_win32_x86_0.120.3.41/BlitzMax/MinGW32x86/i686-w64-mingw32/include/windows.h:72,
                 from C:/Users/catalin/Desktop/programare/BlitzMaxNG/BlitzMax_win32_x86_0.120.3.41/BlitzMax/mod/brl.mod/blitz.mod/blitz_thread.h:11,
                 from C:/Users/catalin/Desktop/programare/BlitzMaxNG/BlitzMax_win32_x86_0.120.3.41/BlitzMax/mod/brl.mod/blitz.mod/blitz.h:28,
                 from C:/Users/catalin/Desktop/programare/BlitzMaxNG/BlitzMax_win32_x86_0.120.3.41/BlitzMax/mod/brl.mod/blitz.mod/.bmx/blitz.bmx.debug.win32.x86.h:4,
                 from M:/GameDev/33 Mosaics/game sol BMX NG/.bmx/main.bmx.gui.debug.win32.x86.h:4,
                 from M:/GameDev/33 Mosaics/game sol BMX NG/.bmx/main.bmx.gui.debug.win32.x86.c:1:
C:/Users/catalin/Desktop/programare/BlitzMaxNG/BlitzMax_win32_x86_0.120.3.41/BlitzMax/MinGW32x86/i686-w64-mingw32/include/winuser.h:2488:26: note: previous declaration of 'GetActiveWindow' was here
   WINUSERAPI HWND WINAPI GetActiveWindow(VOID);
                          ^~~~~~~~~~~~~~~
In file included from M:/GameDev/33 Mosaics/game sol BMX NG/.bmx/main.bmx.gui.debug.win32.x86.c:1:
M:/GameDev/33 Mosaics/game sol BMX NG/.bmx/main.bmx.gui.debug.win32.x86.h:1991:25: error: conflicting types for 'ExtractIconA'
extern BBINT __stdcall  ExtractIconA(BBINT bbt_hWnd,BBBYTE * bbt_File,BBINT bbt_Index);
                         ^~~~~~~~~~~~
In file included from C:/Users/catalin/Desktop/programare/BlitzMaxNG/BlitzMax_win32_x86_0.120.3.41/BlitzMax/MinGW32x86/i686-w64-mingw32/include/windows.h:89,
                 from C:/Users/catalin/Desktop/programare/BlitzMaxNG/BlitzMax_win32_x86_0.120.3.41/BlitzMax/mod/brl.mod/blitz.mod/blitz_thread.h:11,
                 from C:/Users/catalin/Desktop/programare/BlitzMaxNG/BlitzMax_win32_x86_0.120.3.41/BlitzMax/mod/brl.mod/blitz.mod/blitz.h:28,
                 from C:/Users/catalin/Desktop/programare/BlitzMaxNG/BlitzMax_win32_x86_0.120.3.41/BlitzMax/mod/brl.mod/blitz.mod/.bmx/blitz.bmx.debug.win32.x86.h:4,
                 from M:/GameDev/33 Mosaics/game sol BMX NG/.bmx/main.bmx.gui.debug.win32.x86.h:4,
                 from M:/GameDev/33 Mosaics/game sol BMX NG/.bmx/main.bmx.gui.debug.win32.x86.c:1:
C:/Users/catalin/Desktop/programare/BlitzMaxNG/BlitzMax_win32_x86_0.120.3.41/BlitzMax/MinGW32x86/i686-w64-mingw32/include/shellapi.h:87:20: note: previous declaration of 'ExtractIconA' was here
   SHSTDAPI_(HICON) ExtractIconA (HINSTANCE hInst, LPCSTR pszExeFileName, UINT nIconIndex);
                    ^~~~~~~~~~~~
In file included from M:/GameDev/33 Mosaics/game sol BMX NG/.bmx/main.bmx.gui.debug.win32.x86.c:1:
M:/GameDev/33 Mosaics/game sol BMX NG/.bmx/main.bmx.gui.debug.win32.x86.h:1992:37: error: stray '@' in program
extern BBINT __stdcall  SendMessageA@16(BBINT bbt_hWnd,BBINT bbt_MSG,BBINT bbt_wParam,BBINT bbt_lParam);
                                     ^
M:/GameDev/33 Mosaics/game sol BMX NG/.bmx/main.bmx.gui.debug.win32.x86.h:1992:38: error: expected '=', ',', ';', 'asm' or '__attribute__' before numeric constant
extern BBINT __stdcall  SendMessageA@16(BBINT bbt_hWnd,BBINT bbt_MSG,BBINT bbt_wParam,BBINT bbt_lParam);
                                      ^~
In file included from M:/GameDev/33 Mosaics/game sol BMX NG/.bmx/main.bmx.gui.debug.win32.x86.c:1:
M:/GameDev/33 Mosaics/game sol BMX NG/.bmx/main.bmx.gui.debug.win32.x86.h:3807:46: error: stray '@' in program
extern BBINT __stdcall  SystemParametersInfoA@16(BBINT bbt_action,BBINT bbt_param,BBBYTE* bbt_vparam,BBINT bbt_winini);
                                              ^
M:/GameDev/33 Mosaics/game sol BMX NG/.bmx/main.bmx.gui.debug.win32.x86.h:3807:47: error: expected '=', ',', ';', 'asm' or '__attribute__' before numeric constant
extern BBINT __stdcall  SystemParametersInfoA@16(BBINT bbt_action,BBINT bbt_param,BBBYTE* bbt_vparam,BBINT bbt_winini);

I don't know what these errors mean or how to fix them. Please help. How can I find where in the code is the reported problem?

I found this answer by Brucey to the stray '@' issue:
QuoteYou appear to be externing all these yourself? Doesn't Pub.Win32 already expose a lot of these APIs already?

The errors with functions that look like 'CreateMutexA@12' (with the @ included in the function name) are because your extern probably looks something like :
format_code('
Function blah(some args)="blah@12"
')

Because the legacy compiler is generating assembler and knows nothing about the libraries it is interfacing with, one needs to "help" it when referring to certain kinds of Windows functions. So you need to "mangle" the names to match those that are actually in the library.
NG doesn't require this because it will compile the function names correctly at build time.

Here: https://mojolabs.nz/posts.php?topic=105123

I don't know where "win32" extern is or how to edit it so that I can remove the '@'. I also don't know how to check if my required functions are in Pub.Win32 and use them from there.




Pingus

I'm also having the issue so I'm interrested about hints ;)
However if the purpose of migrating your code to NG is to build for Mac64 bits, that issues do not really matter as they are related to specific PC stuff.

Henri

Hi,

just to makes things easier you could concentrate on the 'GetActiveWindow' error.

In your main.bmx file you have function 'GetActiveWindow' or you are including a file that has this function.

Could you find where this function is defined and post it ?

I believe there is block similar to this:
Code (blitzmax) Select

Extern "Win32"
    Function GetActiveWindow()
EndExtern


If you are using MaxIDE, you can search whole folders (and subfolders) for files that contain specific text like Function GetActiveWindow. Use right-hand side treeview and select menu option 'Find in files'. I also use AstroGrep, which is a Windows version of a handy Linux tool for searching text and stuff.

-Henri
- Got 01100011 problems, but the bit ain't 00000001

Ashmoor

@Pingus
"However if the purpose of migrating your code to NG is to build for Mac64 bits, that issues do not really matter as they are related to specific PC stuff."

Yes, that is the purpose  ;) but I must understand my code better before moving on.

@Henri
I figured out how to find stuff and GetActiveWindow() is defined in user32.bmx so I don't need to set an extern for it. I figured out how it works: it returns a byte ptr if current window is active or nothing if it's not active so I can check if my window is active I write it like this If GetActiveWindow()<>Null then bla bla.

Relating to stray '@' I figured out that the things written after the function definition variables are "Function Properties". I still don't know much about it but I am learning.

Code (blitzmax) Select

'old definition was:
Function SystemParametersInfo(action:Int, param:Int, vparam:Byte Ptr, winini:Int) "SystemParametersInfoA@16"

'bmx ng definition is:
Function SystemParametersInfo(action:Int, param:Int, vparam:Byte Ptr, winini:Int) "win32"="WINBOOL __stdcall  SystemParametersInfo(UINT ,UINT ,PVOID ,UINT )!"


That seems to work.


Pingus