assert - cppreference.com
Da cppreference.com.
|
|
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
<metanoindex/>
<tbody> </tbody>
| Elemento definito nell'header <cassert> |
||
|
|
||
La definizione del assert macro dipende un'altra macro, NDEBUG, che non è definito dalla libreria standard.
Original:
The definition of the macro assert depends on another macro, NDEBUG, which is not defined by the standard library.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Se NDEBUG è definito come un nome di macro nel punto in cui il codice sorgente è incluso <cassert>, quindi assert non fa nulla.
Original:
If NDEBUG is defined as a macro name at the point in the source code where <cassert> is included, then assert does nothing.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Se NDEBUG non è definito, i controlli di assert se il suo argomento (che deve avere tipo scalare) confronta uguale a zero. In caso affermativo, assert uscite attuazione specifiche informazioni di diagnostica sul standard error e chiama std::abort. Le informazioni di diagnostica è necessario includere il testo expression, così come i valori dei macro standard __FILE__, __LINE__, e la variabile __func__ standard.
Original:
If NDEBUG is not defined, then assert checks if its argument (which must have scalar type) compares equal to zero. If it does, assert outputs implementation-specific diagnostic information on the standard error output and calls std::abort. The diagnostic information is required to include the text of expression, as well as the values of the standard macros __FILE__, __LINE__, and the standard variable __func__.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Parametri
| condition | - | espressione di tipo scalare Original: expression of scalar type The text has been machine-translated via Google Translate. |
Valore di ritorno
(Nessuno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Esempio
#include <iostream> // uncomment to disable assert() // #define NDEBUG #include <cassert> int main() { assert(2+2==4); std::cout << "Execution continues past the first assert\n"; assert(2+2==5); std::cout << "Execution continues past the second assert\n"; }
Output:
Execution continues past the first assert test: test.cc:8: int main(): Assertion `2+2==5' failed. Aborted
Vedi anche
| affermazione statico | esegue in fase di compilazione affermazione controllo (dal C++11) Original: performs compile-time assertion checking (dal C++11) The text has been machine-translated via Google Translate. |
causa chiusura anomala del programma (senza pulizia) Original: causes abnormal program termination (without cleaning up) The text has been machine-translated via Google Translate. (funzione) [modifica] | |