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

tinytiled: forward references to 'enum' and goto statement errors with g++ #87

Closed
selimanac opened this Issue Mar 29, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@selimanac

selimanac commented Mar 29, 2018

I couldn't find any useful info for these errors :(
As far as I know, c++11 should support forward declaring an enum. Compiling works for C with gcc, but fails with g++. Am I missing something here?

main.cpp/c is just contains include.

#define TINYTILED_IMPLEMENTATION
#include "tinytiled.h"

int main(int argc, char** argv)
{
		return 0;
}

MacOS: Apple LLVM version 9.0.0 (clang-900.0.39.2)
Compiling works for C: gcc -c main.c

When I try compile cpp: g++ -std=c++11 -c main.cpp

./tinytiled.h:97:14: error: ISO C++ forbids forward references to 'enum' types
typedef enum TINYTILED_PROPERTY_TYPE TINYTILED_PROPERTY_TYPE;

./tinytiled.h:1463:2: error: cannot jump from this goto statement to its label

Cannot jump error is available for all tinytiled_expect

Also I try it on Debian: gcc version 6.3.0 20170516
g++ -std=c++11 -fpermissive -c main.cpp

tinytiled.h:97:14: error: use of enum ‘TINYTILED_PROPERTY_TYPE’ without previous declaration
 typedef enum TINYTILED_PROPERTY_TYPE TINYTILED_PROPERTY_TYPE;

tinytiled.h:117:6: error: using typedef-name ‘TINYTILED_PROPERTY_TYPE’ after ‘enum’
 enum TINYTILED_PROPERTY_TYPE
@RandyGaul

This comment has been minimized.

Show comment
Hide comment
@RandyGaul

RandyGaul Mar 29, 2018

Owner

These look like some pretty weird errors. I’ll take a close look tonight. I’ll try using tdm-gcc and see what happens.

Owner

RandyGaul commented Mar 29, 2018

These look like some pretty weird errors. I’ll take a close look tonight. I’ll try using tdm-gcc and see what happens.

@RandyGaul

This comment has been minimized.

Show comment
Hide comment
@RandyGaul

RandyGaul Mar 29, 2018

Owner

Got it building with a couple changes, albeit with a bunch of warnings for goto crossing variable initialization. Problem is g++ is extremely opinionated about goto statements and jumping over initialization. In the case of tinytiled, the code is written well as-is. Adjusting the code to circumvent these warnings results in harder to read code, where variable creation is separated from initialization, muddying the scope and code-readability. So I'm not really interested in fixing these warnings. It would be more detrimental to circumvent these warnings and sacrifice code quality than to simply ignore the warnings.

I used: g++ -fpermissive -std=c++11 -Wall -I. -I.. main.c -o $@

7ae785f

Owner

RandyGaul commented Mar 29, 2018

Got it building with a couple changes, albeit with a bunch of warnings for goto crossing variable initialization. Problem is g++ is extremely opinionated about goto statements and jumping over initialization. In the case of tinytiled, the code is written well as-is. Adjusting the code to circumvent these warnings results in harder to read code, where variable creation is separated from initialization, muddying the scope and code-readability. So I'm not really interested in fixing these warnings. It would be more detrimental to circumvent these warnings and sacrifice code quality than to simply ignore the warnings.

I used: g++ -fpermissive -std=c++11 -Wall -I. -I.. main.c -o $@

7ae785f

@RandyGaul RandyGaul closed this Mar 29, 2018

@selimanac

This comment has been minimized.

Show comment
Hide comment
@selimanac

selimanac Mar 31, 2018

Thank you very much, works like a charm.
Just a little note: built-in osx clang compiler is not support -fpermissive flag. But who cares :)

selimanac commented Mar 31, 2018

Thank you very much, works like a charm.
Just a little note: built-in osx clang compiler is not support -fpermissive flag. But who cares :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment