Wow to write to the status window

KrisKasprzak

Well-known member
I saw this somewhere but don't recall. I want to write to the compiler status window, anyone recall how?

PS not the serial window but the pane just below the code.

tia
 
If you include a #warning or #error message in your code it will be written to the compiler window. The #error message also stops compilation.
I thought there was one for #message but it doesn't work.

e.g. fail if the code isn't being compiled for a T3.6
Code:
#ifndef __MK66FX1M0__
#error This must be compiled for a Teensy 3.6
#endif

Pete
 
I saw this somewhere but don't recall. I want to write to the compiler status window, anyone recall how?

@KrisKasprzak:

Maybe this might work to do what you are looking for:

Code:
# ifndef MY_DEFINE
# pragma message ("MY_DEFINE not found")
# endif

Quite some time ago, when I was tinkering with one of the 3rd-party libraries, I sprinkled "#pragma" lines throughout their source to figure out which code path it took & exactly what it took to make it happy when called by my program. It's been awhile, so I may not have the syntax exactly correct, but that should get you somewhere in the general vicinity (the #ifndef / #endif is not absolutely required if you just want to always put out a message) . . .

Good luck & have fun !!

Mark J Culross
KD5RXT
 
The standard way to do this is to use #error:

Code:
#ifndef MY_DEFINE
#error "MY_DEFINE not found"
#endif

The #pragma message "..." along with #warning "...", #pragma GCC error "...", #pragma GCC waring "...", and #pragma GCC diagnostic type "..." are all GCC extensions. Now in the Arduino environment, you are likely never to use anything besides GCC, but it might be possible, your code is moved to another environment that uses a different compiler.

The #error "..." directive has been part of ISO C and C++ since they were standardized.

Note, #error stops the compilation, as does #pragma GCC error, and #pragma GCC diagnostic error, while #warning, and #pragma GCC warning just emits a message, but does not stop the compilation.
 
Back
Top