CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Error C2061

  1. #1
    Join Date
    May 2009
    Posts
    2

    Error C2061

    Hi

    I've searched in a lot of foruns, including this one, to an answer to this error that is pissing me off. I know that it's about circular dependence, but i just can't make it work. Please take a look to the error message:

    Code:
    1>Compiling...
    1>Iluminador.cpp
    1>c:\vrts_project\vrts_project\vrts_project\ceu.h(13) : error C2061: syntax error : identifier 'Iluminador'
    1>Visualizador.cpp
    1>c:\vrts_project\vrts_project\vrts_project\iluminador.h(36) : error C2061: syntax error : identifier 'Visualizador'
    1>Generating Code...
    1>Compiling...
    1>EstruturaN1_T.cpp
    1>Generating Code...
    1>Compiling...
    1>ActiveLoader.cpp
    1>Ceu.cpp
    1>PickHandler.cpp
    1>Rua.cpp
    1>RuaFake.cpp
    1>SceneLoader.cpp
    1>vrts_main.cpp
    1>EstruturaN1_Fake.cpp
    1>Generating Code...
    1>Build log was saved at "file://c:\VRTS_PROJECT\VRTS_project\VRTS_project\Debug\BuildLog.htm"
    1>VRTS_project - 2 error(s), 1 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    Making it shorter: "Ceu.h" calls "Iluminador.h"; "Iluminador.h" calls "Visualizador.h"; "Visualizador.h" calls another header, "main.h", witch calls almost all other headers to the project. Why only these two is giving errors back?

    Thanks in advance
    Last edited by Salvador37; May 11th, 2009 at 02:20 PM.

  2. #2
    Join Date
    Oct 2002
    Location
    Austria
    Posts
    1,284

    Re: Error C2061

    Sometimes the use of forward declarations and use of pointers and references (instead of objects ) in the headers is the only way out of such situations.
    Kurt

  3. #3
    Join Date
    Apr 2004
    Posts
    102

    Re: Error C2061

    Do all your header files have guards around them? By guard, I mean something like:
    Code:
    #ifndef SOMEFILE_H
    #define SOMEFILE_H
    
    // all the usual header file stuff should go in here
    // between the #define and the #endif 
    
    #endif
    This prevents most of the usual circular definition issues. Every single one of the header files you work with should have them (as a just-in-case).

  4. #4
    Join Date
    May 2009
    Posts
    2

    Re: Error C2061

    Thanks, guys.

    These guards resolved my problem. I didn't know how to deal with them, now its working.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured