Josep Roca, OK, I think understand now. The complaint, while related, is not new to this recent Aug 2018 version change:
Code: Select all
'' since fbc version >= 0.16.0
#include "windows.bi"
dim h as HWND, w as WNDPROC
SetWindowLongPtr( h, GWLP_WNDPROC, w ) '' warning: passing pointer to scalar
fbc windows headers just follow what is in msdn. And in this particular case of SetWindowLongPtr(), I think is to ensure that the code works on 32bit and 64bit windows, passing a pointer of a specific size (seriously, I am guessing a little, I haven't written winapi code in a long while).
To be fair, if fbc was actually being strict about the type checking it would error and abort the compile. Clearly, it's not doing that. Warnings only to indicate that, maybe should have another look.
----
What basic are we comparing to? Maybe it is VB5/6? It accepts just about anything; does that mean it is automatically good for beginners? I don't know. In VB5/6, with WINAPI declare BYVAL/BYREF as ANY, AddressOf, BYVAL arg, undocumented VarPtr(); I think the programmer really needs to understand the WINAPI and how VB works with data types to make WINAPI calls work. Usually, the only indication that the programmer go it wrong is "Bad DLL call" or some such message (sorry, I can't remember the exact message when the VB application crashes)
For example, SendMessage() with 4th param (LPARAM) as pointer or scalar depending on context:
Code: Select all
'' In VB5/6
Option Explicit
'' multiple declares for same WINAPI
Declare Function SendMessagePTR Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function SendMessageNONPTR Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long
Declare Function SendMessageFUNCPTR Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'' undocumented
Declare Function VarPtr Lib "msvbvm60.dll" (Var As Any) As Long
Sub proc()
End Sub
Sub Main()
Dim a As String
Dim b As Long
SendMessagePTR 0, 0, 0, 0
SendMessagePTR 0, 0, 0, ByVal 0
SendMessagePTR 0, 0, 0, a
SendMessagePTR 0, 0, 0, ByVal a
SendMessagePTR 0, 0, 0, VarPtr(a)
SendMessagePTR 0, 0, 0, vbNullString
SendMessagePTR 0, 0, 0, b
SendMessagePTR 0, 0, 0, ByVal b
SendMessagePTR 0, 0, 0, VarPtr(b)
SendMessagePTR 0, 0, 0, AddressOf proc
'' SendMessageNONPTR 0 '' type mismatch
'' SendMessageNONPTR ByVal 0 '' type mismatch
SendMessageNONPTR 0, 0, 0, a
SendMessageNONPTR 0, 0, 0, ByVal a
SendMessageNONPTR 0, 0, 0, VarPtr(a)
SendMessageNONPTR 0, 0, 0, vbNullString
SendMessageNONPTR 0, 0, 0, b
SendMessageNONPTR 0, 0, 0, ByVal b
SendMessageNONPTR 0, 0, 0, VarPtr(b)
SendMessageNONPTR 0, 0, 0, AddressOf proc
'' SendMessageFUNCPTR 0, 0, 0, a '' type mismatch
'' SendMessageFUNCPTR 0, 0, 0, ByVal a
SendMessageFUNCPTR 0, 0, 0, VarPtr(a)
'' SendMessageFUNCPTR 0, 0, 0, vbNullString
SendMessageFUNCPTR 0, 0, 0, b
SendMessageFUNCPTR 0, 0, 0, ByVal b
SendMessageFUNCPTR 0, 0, 0, VarPtr(b)
SendMessageFUNCPTR 0, 0, 0, AddressOf proc
End Sub
And VB5/6 did not directly handle pointers or function pointers directly. Only pass to a WINAPI function. In contrast, fbc, does work directly with both.