error C2061: syntax error
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: error C2061: syntax error

  1. #1
    Join Date
    Dec 2011
    Posts
    8

    Question error C2061: syntax error

    Hi,

    I am creating an .exe project in VS. In that i have included all the files related to it.
    I am getting errors in two files: tidy.c and lexer.c
    --> The errors in tidy.c are as below:
    .........\tidy.c(76): error C2061: syntax error : identifier 'bAbortTidy'
    .........\tidy.c(76): error C2059: syntax error : ';'
    ..
    ..
    some other errors because of error at 76 line
    the code at 76 line is:
    extern bool bAbortTidy;

    --> The errors in lexer.c are as below:
    .........\lexer.c(42): error C2061: syntax error : identifier 'bAbortTidy'
    .........\lexer.c(42): error C2059: syntax error : ';'
    ..
    ..
    some other errors because of error at 42 line
    the code at 42 line no is:
    extern bool bAbortTidy;

    --> The variable "bAbortTidy" is declared in other file "HTMEngine.cpp" as
    bool bAbortTidy = false; // used in tidy.c and lexer.c

    I already included this file then also its showing the above error.
    Also i added all the preprocessor definations, additional dependencies, directory paths of all files.
    It would be better if anyone can guide me in this case.

    Advance Thanks,
    Regards,
    Nagesh

  2. #2
    Join Date
    Dec 2011
    Posts
    8

    Re: error C2061: syntax error

    Hi,
    Again this is Nagesh.

    Related to the above error, if i remove the preprocessor NDEBUG then its showing those errors in the previous post.
    If i include NDEBUG then its giving other errors like:
    c:\newdir\xalan-c-r786300\inc\xalanc\include\vcppdefinitions.hpp(73): fatal error C1189: #error : NDEBUG must not be defined when _DEBUG is defined.

    As i have not defined _DEBUG then also its giving the above error.

    Please guide me in resolving the above error

    Regards,
    Nagesh

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,605

    Re: error C2061: syntax error

    Quote Originally Posted by nageshshugar View Post
    If i include NDEBUG then its giving other errors like:
    c:\newdir\xalan-c-r786300\inc\xalanc\include\vcppdefinitions.hpp(73): fatal error C1189: #error : NDEBUG must not be defined when _DEBUG is defined.
    If you define both NDEBUG and _DEBUG then no compilation will be run, therefore you don't see compilation errors.

    BTW, what is the reason to use .c files in VC++ project?
    Victor Nijegorodov

  4. #4
    Join Date
    Apr 1999
    Posts
    27,446

    Re: error C2061: syntax error

    Quote Originally Posted by nageshshugar View Post
    some other errors because of error at 76 line
    the code at 76 line is:
    extern bool bAbortTidy;

    --> The errors in lexer.c are as below:
    .........\lexer.c(42): error C2061: syntax error : identifier 'bAbortTidy'
    .........\lexer.c(42): error C2059: syntax error : ';'
    Your file extension is ".c", therefore the compiler will compile your code assuming the 'C' language. In the 'C' language, there is no such type as bool. That is probably why you're getting the error.

    If you need to be convinced, create this program, give it a ".c" extension, and try to compile it:
    Code:
    int main()
    {
       bool b;
    }
    Save this to a .c file and try to compile it. Now save it to a .cpp file and try to compile it. You will see that the .c file will fail, and the .cpp file will compile.

    Regards,

    Paul McKenzie

  5. #5
    Join Date
    Dec 2011
    Posts
    8

    Re: error C2061: syntax error

    Hi Paul,

    Yes, your right that in 'C' language there is no bool type, but after getting information from my colleague i came to know that if compile as C++ code(/TP) in (Project->properties->C/C++->Advanced->Compile as) then we can use bool in c.

    After doing this still i am getting another error :
    >c:\newdir\boost_1_43_0\boost\config\auto_link.hpp(106): fatal error C1189: #error : "Incompatible build options"

    I am not getting why this error is coming? when it will come ??

    Can anybody sortout this problem?

    Advance Thanks,

    Regards,
    Nagesh

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,605

    Re: error C2061: syntax error

    Quote Originally Posted by nageshshugar View Post
    ...
    After doing this still i am getting another error :
    >c:\newdir\boost_1_43_0\boost\config\auto_link.hpp(106): fatal error C1189: #error : "Incompatible build options"

    I am not getting why this error is coming? when it will come ??
    Well, I never worked with boost, so I can only suggest you to used Google
    Victor Nijegorodov

  7. #7
    Join Date
    Feb 2002
    Posts
    4,640

    Re: error C2061: syntax error

    Quote Originally Posted by nageshshugar View Post
    Hi Paul,

    Yes, your right that in 'C' language there is no bool type, but after getting information from my colleague i came to know that if compile as C++ code(/TP) in (Project->properties->C/C++->Advanced->Compile as) then we can use bool in c.
    Just to clarify, you are not "using bool in c". When you tell the compiler to compile the file as C++, then it's C++.

    Viggy

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center