| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Whenever you search in PBworks, Dokkio Sidebar (from the makers of PBworks) will run the same search in your Drive, Dropbox, OneDrive, Gmail, and Slack. Now you can find what you're looking for wherever it lives. Try Dokkio Sidebar for free.

View
 

error

This version was saved 14 years, 8 months ago View current version     Page history
Saved by Kenneth Finnegan
on April 6, 2008 at 1:16:40 pm
 

This preprocessor directive can be used to make a file not compile with your own error message saying what's wrong

 

Code:

#error Custom error message saying what is wrong

 

Usage:

int foo(int bar) {

     #error Function foo not yet implemented

}

 


Extensions:

This can be used with #if to check properties of the environment

#if sizeof(int) < 4

     #error sizeof Int is too small, must be at least 4 bytes

#endif


Sources:

https://www.securecoding.cert.org/confluence/display/seccode/DCL03-A.+Use+a+static+assertion+to+test+the+value+of+a+constant+expression

Comments (0)

You don't have permission to comment on this page.