- two (simple) questions about DDK compiler warnings.
- Posted by Sergei V on September 30th, 2007
Hi all,
could somebody please comment the following
problems with code compilation (WINDDK 3790.1830):
1) C4127 -- A code:
** #include <tdikrnl.h>
**TdiBuildAssociateAddress(pIrp, pTdiDevice,
** pfoConnection, NULL, NULL,
** hTransportAddress);
produce compiler warning C4127 (conditional expression constant).
This is because TDI macro is expanded to if(NULL=NULL){...}.
Lowering warning level to /W3 solves the problem, but I do not
like to miss errors like if(a=b){}
Is there a better workaround?
2) winioctl.h -- A code
** #include <windows.h>
** #include <stdio.h>
** #include <winioctl.h>
** #include <strsafe.h>
** #include <winioctl.h>
produce a lot of compiler warnings "macro redefinition".
I failed to find the source and ended up with copying
some code (which is definitely bad) from winioctl.h to my sources.
** #define IOCTL_SERIAL_SET_BAUD_RATE ...
** #define IOCTL_SERIAL_SET_QUEUE_SIZE ...
** #define IOCTL_SERIAL_SET_BREAK_ON ...
What is the source of these warnings?
(I have none when I build a driver. I have them when building
property page for the device manager)
Thanks.
- Posted by Igoogle on October 6th, 2007
On Sep 30, 12:05 pm, "Sergei V" <s...@a.c.ad.e.m.org> wrote:
hi, the warning message is "macro redefinition" , maybe you need add
"#ifndef _XXX_H" such defiante statement int he code .
may this can help you .
- Posted by Ben Voigt [C++ MVP] on October 11th, 2007
"Sergei V" <sv@a.c.ad.e.m.org> wrote in message
news:%23ruk6cxAIHA.4880@TK2MSFTNGP03.phx.gbl...
You can disable just this warning using #pragma warning(disable : 4127)
Then other level 4 warnings will still be issued.
- Posted by SergeV on October 12th, 2007
Yea, you are right absolutely.
I just thought there is a better solution.
Microsoft use macros in their libraries.
Why don't they put in there all the right #pragmas
so that You won't learn them, unless you wish?
Thanks. :-)
"Ben Voigt [C++ MVP]" <rbv@nospam.nospam> wrote in message
news:eidaCWCDIHA.4836@TK2MSFTNGP06.phx.gbl...
- Posted by Colin H on October 12th, 2007
Microsoft macros also fail prefast...... :s
"SergeV" <s_no_spam_v@a_ca.de_m.org> wrote in message
news:%236LZ0UJDIHA.536@TK2MSFTNGP06.phx.gbl...
- Posted by Maxim S. Shatskih on October 14th, 2007
IoSetCancelRoutine is the macro notoriously known for this.
--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com
"Colin H" <colinh@noemail.noemail> wrote in message
news:Oa8iVOKDIHA.3848@TK2MSFTNGP05.phx.gbl...