I allready asked a question about this inside JoBe's Thread about the stl <map> (http://www.daniweb.com/techtalkforums/post252520-10.html), but maybe it's better if i make a new thread about it.

The problem is, when i try to use <map> inside my project i get 2 errors:

C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(16) : error C2143: syntax error : missing ';' before 'namespace'
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(16) : error C2501: 'B' : missing storage-class or type specifiers

When i make a new project (win32 console app), so i have a totally empty main-function everything is fine, i can do everything i want.
BUT,
when i put the following line inside my file:
#include <map>
i get the 2 errors again.

what's going on here?

Dani AI

Generated

Errors that appear inside the compiler's STL headers almost always mean something in the translation unit or project setup is changing how the header is being parsed — not that the shipped header file is broken. As suggested, service packs matter; since already confirmed the VC6 SP5 fixes are present, the next step is to isolate what in the project or the specific source file is interfering.

Common culprits and targeted checks:

  • Precompiled headers. VC6 requires the PCH file header (typically stdafx.h) to be the first include in each .cpp when PCHs are enabled. Mismatched or corrupted PCHs can cause strange syntax errors inside system headers. Try turning PCH off for the TU or rebuild/delete the .pch.
  • Include-order / stray syntax before the include. A missing semicolon or stray brace in earlier code or an included header will scramble parsing of the next header.
  • Macro collisions or odd /D flags. Single-letter or short macros (or a project-wide define) can replace tokens used inside STL headers. Search the project and third-party headers for unexpected #defines.
  • Wrong include path or duplicate headers. A nonstandard copy of the STL headers earlier on the include path will show up here.

Practical steps to inspect what the compiler actually sees:

cl /P /C problem.cpp    // write preprocessed file (problem.i)
cl /E problem.cpp > out.i   // or send preprocess to stdout
findstr /S /N /C:"#define B" *.*    // search the tree for a suspect macro

Work incrementally: build a minimal TU that uses the same compiler/project settings and add includes one at a time until it breaks. If the issue persists after these checks, try compiling the same file in a fresh project with identical compiler options; if it then succeeds, compare project-level settings (preprocessor, include paths, PCH). For long-term relief consider using a newer MSVC or an alternative STL implementation — VC6's compiler has many quirks that are hard to track down.

Recommended Answers

All 2 Replies

what version of the compiler are you using? Have you installed SP5 bug fixes? I have VC++ 6.0 with and do not have your problem.

I have also VC++ 6.0 with SP5, so i don't know what's wrong.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.