diff --git a/headers/posix/assert.h b/headers/posix/assert.h index d916e02e60..628cd4c843 100644 --- a/headers/posix/assert.h +++ b/headers/posix/assert.h @@ -3,19 +3,19 @@ * Distributed under the terms of the MIT License. */ -/* Include guards are omitted, as assert.h is required +/* Include guards are only on part of the file, as assert.h is required to support being included multiple times. - + E.g. the following is required to be valid: - + #undef NDEBUG #include - + assert(0); // this assertion will be triggered - + #define NDEBUG #include - + assert(0); // this assertion will not be triggered */ @@ -24,6 +24,9 @@ #ifndef NDEBUG /* defining NDEBUG disables assert() functionality */ +#ifndef _ASSERT_H_ +#define _ASSERT_H_ + #ifdef __cplusplus extern "C" { #endif @@ -40,6 +43,8 @@ extern void __assert_perror_fail(int error, const char *file, } #endif +#endif /* !_ASSERT_H_ */ + #define assert(assertion) \ ((assertion) ? (void)0 : __assert_fail(#assertion, __FILE__, __LINE__, __PRETTY_FUNCTION__))