With the first scrimmages fast approaching, my team has been hard at work getting our robot together. As part of this, I have developed an algorithm designed to ensure our turret always faces the goal. However, this algorithm makes extensive use of vectors, which received some crucial improvements in C++ 17. However, when I try to make use of these features in VexCode Pro, they don’t seem to exist.
Does VexCode Pro support C++ 17? And if it doesn’t, what is the latest version it supports?
The default compilation in vexcode is C++ 11, it can be changed in the mkenv.mk file. Just set the flag -std=gnu++11 to -std=gnu++17. Sadly, C++20 is not yet supported.
The configuration can be found in vex/mkenv.mk (line 95) on a VSCode project. It should be noted that this probably doesn’t do what you think it does, though.
VEXCode is locked to C++11 (not 14, as earlier claimed). Additionally, adjusting the makefile to -std=gnu++17 will only grant you newer language features, not a newer standard library which is what most people are looking for when they try to adjust this setting.
This is because VEXCode’s stdlib is loaded into memory with VEXCode user programs at runtime rather than uploaded as part of your project’s binary. The standard library used by VEXCode programs is part of the firmware that ships with vexos, and will likely remain that way for the forseeable future. This is done as a measure to reduce filesize, as libstdc++ adds several hundred kilobytes to the resulting binary, and thus spikes upload times.
Your options are:
Polyfill whatever part of std you need back to C++11. Chances are it’s probably possible to do what you want to do without newer standard library features, even if it ends up being uglier or less efficient.
Switch to a different runtime like PROS, which supports up to C++17 on PROS 3 and C++20 on PROS 4 (PROS does this while keeping the binary sizes low through a different form of runtime linking by splitting their binaries in two during the upload process).
Edit the makefiles provided by VEXCode to link against a custom standard library. You’ll need a version of newlib for the Cortex-A9 on arm-none-eabi. I really can’t give guidance on this, since to my knowledge it’s never really been pulled off in a VEXCode project and likely isn’t worth it since you’d be looking at programs weighing upwards of 200kb. C(++) tooling isn’t exactly my strong suit either.