Intentionally cause compile to fail and output warnings

I am writing some code and want to include some error checking functions (check to see if some values are out of the usable range, etc).

Checking for errors is easy. However, is there a way to intentionally cause the compile to fail, or prevent the sketch from being downloaded if an error has been found? Is there a way to print a message in the black area in the Arduino IDE?

Thanks.

Well you can use the preprocessor to do this but that will only work for things known to the preprocessor. For example:

#ifndef __AVR__
#error Architecture not supported.
#endif

or:

#ifndef __AVR__
#warning Architecture not supported.
#endif

or

#ifndef __AVR__
#pragma message "Architecture not supported."
#endif

Prototype a function for each message using the error attribute...

void TinyDebugSerialBadBaud( void ) __attribute__((error("Serial (TinyDebugSerial) supports three baud rates: 9600, 38400, or 115200.")));

void TinyDebugSerialBaudMustBeConstant( void ) __attribute__((error("The baud rate for Serial (TinyDebugSerial) cannot be changed at run-time.  Use 9600, 38400, or 115200.")));

Call the function under the conditions that should cause the compiler to halt...

      if ( __builtin_constant_p( baud ) )
      {
        if ( baud == 9600 )
        {
          _writer = &tdsw9600;
        }
        else if ( baud == 38400 )
        {
          _writer = &tdsw38400;
        }
        else if ( baud == 115200 )
        {
          _writer = &tdsw115200;
        }
        else
        {
          TinyDebugSerialBadBaud();
        }
      }
      else
      {
        TinyDebugSerialBaudMustBeConstant();
      }