Enums in Processing 2.0

PriestVallon picture PriestVallon · Nov 13, 2012 · Viewed 10.9k times · Source

This question refers to version 1.2.1 and it doesn't compile at a different part so it's not a duplicate.

I want to use enums in Processing. I've read they work better in a separate file so I have done that. This code compiles correctly:

enum Status
{
    STOPPED,MOVING
};

But when I have this code

Status status;

in a different file it gives me the following error:

Unrecognized type:46 (ENUM_DEF)

I know enums aren't supported in earlier versions of Processing but are they supported in version 2.0? If so what's cause the error?

Answer

spex picture spex · Nov 14, 2012

When you make a new tab for your enum, are you appending .java? In your case, is your new tab named Status.java?

Your code compiles fine for me in Processing 2.0b6 with the main tab contents:

Status status;

And a new tab named Status.java with the contents:

enum Status
{
    STOPPED,MOVING
};