Code Analysis Failing to build due to comdef.h

I get the following error when trying to run code analysis on one of our apps. When VSTS tries to compile it it bombs in comdef.h

Error 1 error C2220: warning treated as error - no 'object' file generated C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\comdef.h 264
Warning 2 warning C6386: Buffer overrun: accessing 'argument 1', the writable size is '1*0' bytes, but '32' bytes might be written: Lines: 233, 234, 241, 251, 252, 253, 254, 258 c:\program files (x86)\microsoft visual studio 8\vc\include\comdef.h 258

Any Clues on a work around



Answer this question

Code Analysis Failing to build due to comdef.h

  • Behrooz PB

    It is VS 2005 team system configured for a tester on Vista 64 bit RC2 build 5744. I did find by running code analysis on the release config it worked but running code analysis on debug failed. Compiling for a normal build either way worked just fine

    The debug flags that don't work are

    /Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_VC80_UPGRADE=0x0710" /D "_MBCS" /Gm /EHsc /RTC1 /MTd /Yu"stdafx.h" /Fp"Debug\Facilitator.pch" /Fo"Debug\\"

    /Fd"Debug\vc80.pdb" /W4 /WX /nologo /c /ZI /TP /errorReport:prompt

    And the release that does provide me code analysis is

    /O2 /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "_VC80_UPGRADE=0x0710" /D "_MBCS" /FD /EHsc /MT /Yu"stdafx.h" /Fp"Release\Facilitator.pch" /Fo"Release\\"

    /Fd"Release\vc80.pdb" /W4 /nologo /c /Zi /TP /analyze /errorReport:prompt

    I stripped all the includes out because I am not sure how my company would feel about that.. If you need Ill send em to you in email. Thank you very much for the help.


  • JungleMonkeyMike

    This is a known issue which should be fixed in future versions. To workaround this currently, the best way is to suppress the warning when you include it:

    #pragma warning (push)
    #pragma warning (disable: 6386)
    #include <comdef.h>

    #pragma warning (pop)

    If you're indirectly including comdef.h, just put the #pragma's around the root header file.

    Thanks,

    Anshuman Srivastava - VSTS Developer


  • Thomas S. Andersen

    Thanks for calling this to our attention, I will investigate. To help us understand this issue can you let me know:

    Is this with VS 2005 release, or with Service Pack 1 Beta

    Is this on Vista or other Operating System 32 bit or 64 (From above it looks like this is on x64, just wanted to verify)

    Does your project have any build flags or defines set other than the default

    Thanks,
    Dave Lubash
    Visual Studio Team Developer


  • quiklearner

    Thank You Dave and Thank You Anshuman I will implement the work around as you have described.
  • Code Analysis Failing to build due to comdef.h