[LLVMdev] MS C++ gives error C2371 on this code while (obviously) gcc compiles it fine

Yanko yhdezalvarez at gmail.com
Thu Oct 2 08:12:58 PDT 2008


Taken from tools/llvmc2/CompilationGraph.cpp:
...
    for (typename C::const_iterator B = EdgesContainer.begin(),
           E = EdgesContainer.end(); B != E; ++B) {
      const Edge* E = B->getPtr();
...

MS C++ compiler (VS 2008) gives:
...
CompilationGraph.cpp
..\..\..\llvm\tools\llvmc2\CompilationGraph.cpp(58) : error C2371:
'E' : redefinition; different basic types
        ..\..\..\llvm\tools\llvmc2\CompilationGraph.cpp(57) : see
declaration of 'E'
...

While GCC compiles it fine. (I'm assuming it does, 'cause almost
everyone here uses gcc)

Changing the code to
...
    for (typename C::const_iterator B = EdgesContainer.begin(),
           End = EdgesContainer.end(); B != End; ++B) {
      const Edge* E = B->getPtr();
...
makes the code compilable by MS C++. But as a curiosity (and I really
don't know the answer because I can barely read C++): Which compiler
got it right?




More information about the llvm-dev mailing list