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

Compilation doesn't succeed for K&R style blocks #88

Open
MeltyPlayer opened this issue Nov 23, 2024 · 2 comments
Open

Compilation doesn't succeed for K&R style blocks #88

MeltyPlayer opened this issue Nov 23, 2024 · 2 comments

Comments

@MeltyPlayer
Copy link

I've just started using VUEngine, this is incredibly impressive! I especially like how you've set up a transpiler that allows for object-oriented programming while still targeting C.

I was trying to set up a barebones test class, and was noticing weird errors in the log like "unused field" and "_this" not defined. I couldn't figure out what the issue was for the life of me, so I kept tweaking my code until it looked like the code from the sample project. These errors only finally went away when I switched from using K&R style blocks (I personally find these more readable) to Allman style blocks, i.e. from:

while (x == y) {
    foo();
    bar();
}

to

while (x == y)
{
    foo();
    bar();
}

Ideally, the transpiler should work regardless of how the lines are formatted, so I wanted to report this as a minor issue.

Keep up the good work, excited to see your future developments on VUEngine and VUEngine Studio!

@jorgeche
Copy link
Member

Heya, thanks!

Actually, that behavior is expected, although not ideal and definitively not well documented. Having said that, I tried to replicate it by using K&R style both in header files, method definitions and inside functions and, contrary to my expectations, I was not able to reproduce the error. All of the following compiled without trouble:

// WireframeManager.h:
singleton class WireframeManager : ListenerObject {

/// @protectedsection

// WireframeManager.c:
void WireframeManager::reset(){

WireframeManager::enable(this);

// WireframeManager.c:
void WireframeManager::reset(){

WireframeManager::enable(this);

// WireframeManager.c:
Wireframe WireframeManager::createWireframe(const WireframeSpec* wireframeSpec, SpatialObject owner){
NM_ASSERT(NULL != wireframeSpec, "WireframeManager::createWireframe: null wireframeSpec");

if(NULL == wireframeSpec){
	return NULL;
}

Are you using the version of the engine provided with VUEngine Studio or are you cloning it from its repo? While I don't remember explicitly adding support for K&R style blocks, this might have been addressed by other fixes in the last couple of weeks since I'm unable to reproduce these -expected- errors.

@jorgeche
Copy link
Member

Actually, I just have been able to reproduce it. Will try to make it work.

Thanks for reporting!

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

No branches or pull requests

2 participants