Error Catching in V5 pro C++

Does anyone know of ways to throw exceptions when there are errors as you would in C++.
I understand error catching, but wanted to ask if anyone else has thought of ways to do this before I spend time researching on my own.

The default makefile created with VEX Code Pro C++ includes the -fno-exceptions switch passed to the compiler. This means that if you have try ... catch blocks or use throw to raise an Exception, the compiler will error out.

I’m not entirely sure why that decision was made, nor what the implications of removing it are. Perhaps @jpearman would be able to share insight?

4 Likes

Just removing the -fno-exceptions flag will work, sort of, you will probably get a generic error, I would need to look into that. Part of the issue is how we implement the standard library that VEXcode uses in vexos, we link against a reference file but the code is actually on the brain, and was built with the -fno-exceptions flag set. The reason for stdlib being in vexos is to reduce program size. For example, a typical program using some standard library functions may be 250k linked against stdc++ in the usual way, linked against our reference file it can be in the 5-10k range. With a direct USB connection, 250k download is not an issue, but doing that wirelessly is not fun. That can be changed also in the build files, but as I said, executables will be big.

5 Likes