Perhaps by checking for the type WINAPI? The C/C++ header files are full of them:coderJeff wrote:How could we do this? Seriously, do you have any ideas? From fbc's point of view it doesn't really know the difference between an API call and some other function. Linux users won't care about this, so it would WINAPI specific.jj2007 wrote:On Windows, most of the warnings are just confusing. Those related to API calls should be off by default.
Code: Select all
WINAPI
ExitProcess(
__in UINT uExitCode
);
Code: Select all
HWND CreateWindowExA(
DWORD dwExStyle,
LPCSTR lpClassName,
LPCSTR lpWindowName,
DWORD dwStyle,
int X,
int Y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam
);
Now, as a Masm or GfaBasic programmer, I read the doc and make sure that I don't pass real nonsense to CreateWindowEx. But I would never bother to create a menu (in the case of the parent window) with the "correct" HMENU type. It's a DWORD, fullstop. See what happens with no w level set:Type: HMENU
A handle to a menu, or specifies a child-window identifier, depending on the window style. For an overlapped or pop-up window, hMenu identifies the menu to be used with the window; it can be NULL if the class menu is to be used. For a child window, hMenu specifies the child-window identifier, an integer value used by a dialog box control to notify its parent about events.
Code: Select all
hStatic=CreateWindowEx(0, "static", "start typing now...",_
WS_CHILD Or WS_VISIBLE, 3, 1, 285, 20, hWnd, 100, 0, 0)
Code: Select all
C:\AllBasics\FreeBasic\tmp\TmpFile.bas(109) warning 1(1): Passing scalar as pointer, at parameter 10 of CREATEWINDOWEX()
This is extremely messy, but it compiles just fine. And FB "knows", somehow, magically, that "start typing now..." in this context should be translated as a pointer to a zero-delimited string. Instead, when you try the very similar SendMessageW(hStatic, WM_SETTEXT, 0, "ok"), it throws an error, and the only way to fix it is spending some time with Google, do a lot of trial and error, and finally arrive at this awkward construct: SendMessageW(hStatic, WM_SETTEXT, 0, StrPtr("ok")) - which is NOT required for the strings in MessageBox(...). All this is utterly confusing, and puts me off as an experienced programmer. If I was a newbie, I would run away as fast as I could.
The obsession with types is C/C++, not BASIC. Every time I boot my machine, Adobe asks me to install a new, better and safer version. I am sure there are "professional" programmers at work, but they are probably hypnotised by endless pages of obscure type check warnings. Maybe one day they would deliver a really safe product if the Adobe CEO forced them to work in QBASIC...
So, my constructive recommendations:
- if FB discovers a WINAPI, let it be tolerant (unless user expresses explicitly an urgent desire to check everything, e.g. as -w torture)
- if FB discovers a WINAPI, let it translate quoted strings to zstring pointers,