Determining Teensyduino version at compile-time

Status
Not open for further replies.

jstck

New member
Is there a way to determine what version of Teensyduino is used when building a project, through a defined constant or something similar?

I'm looking both for ways to just raise an #error if it's an incompatible version, or even have separate bits of code to handle differences between versions. One example is usbMIDI.sendPitchBend(), where any version "works the same" (as in it compiles and runs), but the actual parameter value is treated differently depending on if you're before or after Teensyduino 1.4.0.

If there was some defined constant to look at it would be trivial to handle, but I haven't found anything looking obvious through the library code. Now we have to tell users to change a constant in the code to handle this if they're on an old version. Sometimes it's feasible to require users to upgrade and sometimes not, but even then it would be helpful to be able to detect the version difference.
 
You can use the pre-defined macro TEENSYDUINO, i.e.

Code:
#if (TEENSYDUINO < 145)
#error "You need at least Teensydunio 1.45 to build this module"
#endif

You can see what is defined by enabling verbose compilation option in the File -> Preferences menu.
 
By the way, is there some reasonably comprehensive documentation for what the various available preprocessor defines/macros are, and their possible values? (Things like all the different USB types)
 
Status
Not open for further replies.
Back
Top