static_assert - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# static_assert

From cppreference.com
< c‎ | error

Defined in header `<assert.h>` |  |
#define static_assert _Static_assert |  |

This convenience macro expands to the keyword _Static_assert

### [edit] Example

Run this code

    #include <assert.h>
    int main(void)
    {
        static_assert(2 + 2 == 4, "2+2 isn't 4");      // well-formed
        static_assert(sizeof(int) < sizeof(char),
                     "this program requires that int is less than char"); // compile-time error
    }

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/error/static_assert&oldid=70417"