Microsoft KB Archive/325134

= Error message when you compile an ATL attributed project in Visual C++ .NET: &quot;MIDL2003 : redefinition&quot; =

Article ID: 325134

Article Last Modified on 1/4/2006

-

APPLIES TO


 * Microsoft Visual C++ .NET 2002 Standard Edition

-



This article was previously published under Q325134



SYMPTOMS
When you compile an ATL based attributed project in Visual C++ .NET, you may receive the following error message from MIDL compiler:

error MIDL2003 : redefinition : IMyInterface



CAUSE
This behavior occurs under the following conditions:
 * Your project uses attributes.

-and-
 * Your project does not use /ZI (Program Database for Edit&Continue), to build debug information. (Therefore, in release builds, this problem can occur easily.)

-and-
 * You use #include to include a header file, which can result in entries being added to the project's IDL file two or more times (in different source files) if either the case or the path is different in the name of each of the header file entries that is added to the different source files.

When all of these conditions exist, the compiler treats each instance of the header file that you used #include to include as a different file, and then adds the duplicate entries to the compile-time generated IDL file, which causes the error.



RESOLUTION
To avoid this behavior, use the same case and the same path for each instance of the header file in each source file when you use #include to include the header, so that #include is the same in every source file.



STATUS
This bug was corrected in Microsoft Visual C++ .NET 2003.



Steps to Reproduce the Behavior
To reproduce the problem, follow these steps:
 * 1) In Visual C++ .NET, create a new ATL Project. Verify that support for attributes is turned on. Name this project TestProj.
 * 2) Add an ATL Simple Object to this project. Name this object TestObj; the header file that is created is named TestObj.h.
 * 3) In TestProj.cpp, add the statement, #include &quot;testobj.h&quot;. (Note that the statement is all lowercase.)
 * 4) Change the build configuration to Release.
 * 5) Right-click TestProj in Solution Explorer, then choose properties.
 * 6) Click C/C++, then set Debug Information Format to Disabled.
 * 7) Expand Linker->Debug, then set Generate Debug Info to No.
 * 8) Click OK.
 * 9) Build the project.

