Processing got a pre-processor which converts Processing's Java Mode into a valid Java program in order to be compiled.
IMO, it'd be trivial to add some basic parser directives like #define, #ifdef, #ifndef to Processing's pre-processor.
But it seems most of Processing devs consider such as Java heresy, even though Processing isn't bound to Java only!
Actually, Processing's pre-processor needs an urgent revamp in order to make it compatible w/ Java 8 and fix very old outstanding bugs!
Even today, pre-processor isn't compatible w/ Java 5's enum! Neither accept Unicode names for variables, classes & methods!
I've never formally made the proposal myself. But others have already tried to ask for directive inclusions in order to make a Processing code flexible enough to be "compiled" for other modes beyond "Java Mode"!
But the refusal is in the lines that "I don't feel that doing so is Java style". [-(
Answers
Technically, no. #include actually adds the content of the file to the current file, like a copy / paste operation. Java cannot do that.
What is traditionally done is putting the definitions in an interface, in a .java file of same name. Eg.
If you put the file in a sketch folder, it will load as a tab, and you can access the constants like:
and so on.
Note that variables in an interface are implicitly
public static final
.Processing got a pre-processor which converts Processing's Java Mode into a valid Java program in order to be compiled.
IMO, it'd be trivial to add some basic parser directives like #define, #ifdef, #ifndef to Processing's pre-processor.
But it seems most of Processing devs consider such as Java heresy, even though Processing isn't bound to Java only!
Actually, Processing's pre-processor needs an urgent revamp in order to make it compatible w/ Java 8 and fix very old outstanding bugs!
Even today, pre-processor isn't compatible w/ Java 5's
enum
! Neither accept Unicode names for variables, classes & methods!"most of Processing devs consider such as Java heresy"
Really? You made a proposal which have been rejected because it isn't a Javaism?
I've never formally made the proposal myself. But others have already tried to ask for directive inclusions in order to make a Processing code flexible enough to be "compiled" for other modes beyond "Java Mode"!
But the refusal is in the lines that "I don't feel that doing so is Java style". [-(