Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Wow to write to the status window

  1. #1

    Wow to write to the status window

    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

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,544
    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

  3. #3
    Senior Member
    Join Date
    Apr 2020
    Location
    DFW area in Texas
    Posts
    191
    Quote Originally Posted by KrisKasprzak View Post
    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

  4. #4
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,969

    Cool

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •