bmx-ng / bcc

A next-generation bcc parser for BlitzMax
zlib License
33 stars 13 forks source link

Normal Debug build EAVs, GDB Debug build works - only affects x86 builds #654

Open GWRon opened 3 months ago

GWRon commented 3 months ago

Hotcakes at discord mentioned having an issue with some "old" function Grey Alien Games had in his "publicdomain.bmx":

I extracted that functionality and made a sample.bmx out of it (keeping the BlitzMaz intact :p):

SuperStrict
Framework Brl.StandardIO
Import Pub.Win32

'AERO SPECIFIC
'by col (Dave) from BlitzMaz forums
Global DwmapiDLL:Byte Ptr = LoadLibraryA("dwmapi.dll")
Global IsAeroEnabled(pfEnabled:Int Var)

If DwmapiDLL
    Print "loaded DLL"
    IsAeroEnabled = GetProcAddress(DwmapiDLL,"DwmIsCompositionEnabled")
EndIf

Global AeroState%
If DwmapiDLL IsAeroEnabled(AeroState)
'END OF AERO SPECIFIC

Print AeroState
Delay(2000)

Compile this on Windows as x86 debug build. Compile a "normal debug build" and it EAVs. Compile a "gdb"-debug-build and it runs.

Maybe of help The EAV comes up AFTER the "delay()" - so not right when accessing the function. Maybe something is cleaning up where it should not clean up - but why does it work though with the GDB info at hand (isnt this just a "code comment"?)

I am not sure if the code is even "correct" - the function normally returns a HRESULT - so I also tried different ways of including thw "dwmapi" but they failed already during linking state:

SuperStrict
Framework Brl.StandardIO
Import Pub.Win32
'Import "-dwmapi" 'seems not to "find something"
'Import "-ldwmapi" 'neither does this

'direct C code ...
'!#include <dwmapi.h>

Extern "win32"
    Function IsAeroEnabled:Int(pfEnabled:Int Var)="HRESULT DwmIsCompositionEnabled(WINBOOL *)!"
End Extern

Global AeroState%
Print IsAeroEnabled(AeroState)
'END OF AERO SPECIFIC

Print AeroState

While the normal "imports" fail with undefined references, the "raw c code"-one fails with some unallowed stuff in class error indicating that I did incorrect again.

C:/Tools/BlitzMax/MinGW32x86/i686-w64-mingw32/include/uxtheme.h: In function '_bb_main':
C:/Tools/BlitzMax/MinGW32x86/i686-w64-mingw32/include/uxtheme.h:212:25: error: invalid storage class for function 'SetWindowThemeNonClientAttributes'
  212 | static __inline HRESULT SetWindowThemeNonClientAttributes(HWND hwnd,DWORD dwMask,DWORD dwAttributes)
      |  

But this is just "side information" (there is the EAV - and there is the functionality I guess Hotcakes or someone else wanted to have).

GWRon commented 3 months ago

According to @davecamp this solves the "functionality" part - but I still am unsure why the gdb-information generation had an effect regarding the EAV (...not EAVing).

Global IsAeroEnabled:Int(pfEnabled:Int Var)"Win32"

(only 32bit builds care for the "win32"-extension)