Thanks a lot for the quick and helpful answer, Don.
You need to enable warning 4013.
I’ve added “#pragma warning(error: 4013)” and it does exactly what I
was hoping for.
Now I have to wonder about your environment since most WDK’s and
DDK’s have a #pragma to set that to be an error.
Where do they have that #pragma? In some header file?
I’m using batch compiling. My x64 bat starts like this:
@set OLDDIR=%CD%
@call C:\WINDDK\3790.1830\bin\setenv.bat C:\WINDDK\3790.1830 fre AMD64 WNET
@set Include=c:\winddk\3790.1830\inc\ddk\wnet;c:\winddk\3790.1830\inc\crt;c:\winddk\3790.1830\inc\wnet
@set Lib=C:\WINDDK\3790.1830\lib\crt\amd64;C:\WINDDK\3790.1830\lib\wnet\amd64;C:\WINDDK\3790.1830\lib
@chdir /d %OLDDIR%
@cl …
Is there anything else I need to do?
Thanks, Mathias.
2016-07-28 12:51 GMT+02:00 Don Burn :
> You need to enable warning 4013. Now I have to wonder about your environment since most WDK’s and DDK’s have a #pragma to set that to be an error.
>
>
> Don Burn
> Windows Driver Consulting
> Website: http://www.windrvr.com
>
>
>
> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of madshi
> Sent: Thursday, July 28, 2016 6:37 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] cl compiler switch to disable function prototype “guessing”?
>
> Hi there,
>
> using “cl” (still using Windows 2003 DDK, for some reason) to compile my driver, I’ve stumbled over the following problem:
>
> When compiling a “c” file which calls a function which is not defined in any of the included headers, the compiler simply seems to guess the calling convention, parameters and return type, instead of complaining. The linker might later complain, if the function isn’t found anywhere. But if the function is properly defined in some other c/h file, then the linker is happy and no warning is reported anywhere.
>
> Practically, I had the compiler guess an “int” return type, while it really was a “BOOLEAN” return type. Consequently, the real function was compiled to “xor al, al”, but the caller was compiled to “test eax, eax”, which resulted in the return value being seen as “TRUE” while it really was meant to be “FALSE”.
>
> So my question is: Can I force “cl” to error out if a function isn’t found in any header file, instead of just guessing the function prototype? I’ve looked through all the compiler options, but couldn’t seem to find anything. I’m already using “/WX”.
>
> I hate compilers trying to be clever… If at least it had posted a warning like “function definition “x” not found, I’m guessing now”, then it wouldn’t have cost me hours to locate the problem.
>
> Thanks, Mathias.
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at http:
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at http:</http:></http:></http:></http:></http:></http:>