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

Class does not exist error when sketch only contains class definitions #5076

Closed
KevinWorkman opened this issue May 19, 2017 · 6 comments
Closed

Comments

@KevinWorkman
Copy link

From this Stack Overflow post:

Paste this into the Processing editor:

class One{
  Two two;
}

class Two{
  One one;
}

You'll get an error on line 2 saying The class "Two" does not exist. Now reverse the order of the classes:

class Two{
  One one;
}

class One{
  Two two;
}

Now you get an error on line 2 saying The class "One" does not exist. Apparently the order matters with class definitions?

But now if you add a setup() function to the sketch, everything is hunky-dory:

void setup(){}

class Two{
  One one;
}

class One{
  Two two;
}
@benfry
Copy link
Contributor

benfry commented May 20, 2017

Why would you do this?

Processing is not a Java IDE. The code in question doesn't make any sense.

Is this trying to make something or just figuring out weird ways to break the preprocessor?

@KevinWorkman
Copy link
Author

I'm guessing that the OP started writing a sketch that was going to require classes, so added the class definitions, and then got scared when they started seeing an error.

@benfry
Copy link
Contributor

benfry commented May 20, 2017

I think there are better ways for us to spend all the time I don't have to fix the other 335 issues in here… Really appreciate you keeping an eye on SO, though at the end of the day this is too far into “why isn't this a Java IDE?” territory.

@benfry benfry closed this as completed May 20, 2017
@KevinWorkman
Copy link
Author

I understand, and I'm with you. Just thought it was slightly strange behavior. Although now that I'm thinking about it, it makes more sense since I gather that there are two kinds of sketch: "script-like" sketches that don't contain functions (just functions calls), and "real" sketches that contain functions like setup() and draw(). This program tries to be something in the middle, which is why it doesn't work. I'll communicate that back to the OP. Thanks for taking the time to reply.

@benfry
Copy link
Contributor

benfry commented May 20, 2017

Yeah, makes sense—thanks again.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants