AndrewDavidson.com.  We don't reinvent the wheel... we just make reinventing the wheel easier. Visit PDFCalendar.com for free customizable printable calendars.
Home
Resources
Software
Links
Articles
About
About Drew
Contact
Feedback
Subscribe to our Newsletter:
Printer-Friendly
© 1999-2024
Andrew Davidson.
All Rights Reserved.

Visual C++ Cryptic Error Messages... And How to Fix Them

Helpful hints for when you are compiling with Visual C++ 6.0

These hints are mainly notes to myself about errors that I found to be fairly cryptic. I hope you find these explanations useful.


ERROR MESSAGE:

Linking... LINK : warning LNK4098: defaultlib "LIBCMTD" conflicts with use of other libs; use /NODEFAULTLIB:library
 

WHAT THIS MEANS:

You have included multiple project files, and they have different settings under Project menu, Settings menu item, Project Settings dialog, C/C++ tab, Code Generation category, "Use Run-time library" options menu. That is, some of your projects probably have "Debug Multithreaded DLL" and others have "Debug Multithreaded". Or whatever. They are different and they should all be the same.
 

HOW TO FIX IT:

Set all the projects to the same "Use Run-time library" configuration.


ERROR MESSAGE:

C:\dev\file.c(467) : error C2143: syntax error : missing ';' before 'type'
 

WHAT THIS MEANS:

If you are not actually missing a semicolon, you are probably compiling a C file instead of a C++ file, and you have a variable declaration in the middle of a {} block (instead of at the top). In C, variable declarations are allowed only at the top of a {} block.
e.g. wrong:
{
   int i = 3;
   CallARoutine(i);

   int j = 2;
   CallARoutine(j);
}

e.g. right:
{
   int i = 3;
   int j = 2;

   CallARoutine(i);
   CallARoutine(j);
}
 

HOW TO FIX IT:

Move the variable declaration to the top of the block, or add a new block to contain that variable declaration, or change your files to be .cpp and thus use C++ instead of C.


ERROR MESSAGE:

MyDLL.exp : warning LNK4070: /OUT:MyDLLSomething.dll directive in .EXP differs from output filename "Debug/MyDLL.dll"; ignoring directive
 

WHAT THIS MEANS:

You are building a DLL, and the output file name you have specified in Project menu: Settings menu item: Link tab: General category: Output file name edit box is different from the name specified on the "LIBRARY" line in the .def file. E.g. Your def file might look like this:
LIBRARY MyDLLSomething
EXPORTS
	StartupDLL    @1
	ShutdownDLL   @2
	... etc ...
In this example the error message will be generated if "MyDLLSomething" is not specified as the output file name in the Project Settings dialog box.
 

HOW TO FIX IT:

Note that this is just a warning. The name specified in the Output File name box has precedence over the def file. But if you want to make the warning go away, change the .def file to match the name specified in the Project Settings dialog box.


ERROR MESSAGE:

C:\dev\proj\file.cpp(282) : fatal error C1010: unexpected end of file while looking for precompiled header directive
 

WHAT THIS MEANS:

You didn't include a precompiled header from a source file in a project that has precompiled headers turned on.
 

HOW TO FIX IT:

Include the header.


ERROR MESSAGE:

error C2143: syntax error : missing ';' before 'PCH creation point'
 

WHAT THIS MEANS:

you probably forgot a semicolon in an included header file (like after a class definition) even though this error can occur in a different file (like the source file that includes the header file that is missing the semicolon)
 

HOW TO FIX IT:

put the semicolon there


ERROR MESSAGE:

error C2040: 'gDownloadLog' : 'class TextDArray *' differs in levels of indirection from 'class TextDArray'
 

WHAT THIS MEANS:

somewhere you've defined "extern TextDArray gDownloadLog" and you are trying to change the actual definition to TextDArray *gDownloadLog.
 

HOW TO FIX IT:

change the extern to TextDArray *gDownloadLog to match.
Post this article to del.icio.us