Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.3.3 doesn't compile with MSVC 2003 #589

Closed
Jmbryan opened this issue Feb 9, 2016 · 4 comments
Closed

Version 1.3.3 doesn't compile with MSVC 2003 #589

Jmbryan opened this issue Feb 9, 2016 · 4 comments

Comments

@Jmbryan
Copy link

Jmbryan commented Feb 9, 2016

I'm using Catch in a legacy project that uses MSVC 2003. After updating Catch to v1.3.3 I now get these compiler errors:

error C2061: syntax error : identifier '__LINE__Var'
error C2072: 'catch_internal_Section' : initialization of a function
fatal error C1903: unable to recover from previous error(s); stopping compilation

It has something to do with the SECTION macro. The prior version of Catch was working great and I will revert back to that version for now. Here is the header info of the prior working version:

"Generated: 2013-02-19 08:44:57.311773"

@philsquared
Copy link
Collaborator

If the "prior version" was from 2013 then, well, a lot has changed in the last three years!

In any case the line that would be causing your error is:

        if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, name, desc ) )

where INTERNAL_CATCH_UNIQUE_NAME just appends the line number to the identifier it is passed. I don't believe this part has really changed since the start.

From your error message it does look like __LINE__ is not being expanded correctly - nor is it being pasted with the root identifier. I don't know why this might be.

I don't have access to a VS2003 compiler to test it with, but you might want to experiment, outside of Catch, reproducing the INTERNAL_CATCH_UNIQUE_NAME macro to see how it behaves (it's actually a set of three macros).

@onqtam
Copy link

onqtam commented Aug 3, 2016

I think I've hit this same issue - but with VC++6 - see here

The minimal example used to reproduce it was this:

#define STR_CONCAT_IMPL(s1, s2) s1##s2
#define STR_CONCAT(s1, s2) STR_CONCAT_IMPL(s1, s2)
#define ANONYMOUS(x) STR_CONCAT(x, __LINE__)

struct Subcase
{
    Subcase(const char* name, const char* file, int line) {}
    operator bool() const { return true; }
};

#define MYMACRO(name) if(const Subcase & ANONYMOUS(AUTOGEN_VARIABLE_) = Subcase(name, __FILE__, __LINE__))

int main() {
    MYMACRO("") {}
    return 0;
}

This was my conclusion:

this turned out to be a compiler bug.
Turning off Edit and Continue from the debug info fixed the problem (the /ZI command line option)

@horenmar horenmar added the Resolved - pending review Issue waiting for feedback from the original author label Jan 8, 2017
@horenmar
Copy link
Member

horenmar commented Jan 8, 2017

Unless turning off edit and continue doesn't help with VS2003, I am going to close this soon.

@philsquared
Copy link
Collaborator

I think we can close this now. If @Jmbryan or @onqtam (or anyone else) still have issues with it feel free to reopen (preferably with more details).

@philsquared philsquared removed the Resolved - pending review Issue waiting for feedback from the original author label Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants