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

A failing construct will fail an entire statement list within an if directive. #227

Open
izackp opened this issue Nov 22, 2021 · 0 comments

Comments

@izackp
Copy link

izackp commented Nov 22, 2021

Example:

//vec2d.hpp
//c2nim --debug --cdecl --cpp --header vec2d.hpp
//c2nim version: 0.9.18

class Vector2; 
#if !VECTORMATH_MODE_SCE
class Vector2
{
    float mX;
    float mY;

public:
    inline Vector2() { }
    inline Vector2(float x, float y);
};
inline Vector2::Vector2(float _x, float _y)
    : mX(_x), mY(_y)
{
}
#endif

Removing the if statement will allow c2nim to create functions for the constructors and type while failing for the last construct. However, with the if directive everything inside it fails.

I believe we should be less strict with failing in this case. I may come up a fix for this in my free time, but until then I'm creating an issue here.

As for the error causing the failing construct, Vector2::Vector2 seems to be read as a return value inside of declarationWithoutSemicolon at which point the next parentheses makes the parser think its reading a function pointer declaration rather than an inline constructor.

Also, the title of the issue is what I believe is happening so far... I'm not 100% sure yet.

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

1 participant