spinn_common 7.2.2
Support code for SpiNNaker applications.
Loading...
Searching...
No Matches
static-assert.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013 The University of Manchester
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
47#ifndef __STATIC_ASSERT_H__
48#define __STATIC_ASSERT_H__
49
50#ifdef __GNUC__
52
53#define static_assert(predicate, msg) \
54 _Static_assert(predicate, "msg")
55
56#else
57#define COMPILE_TIME_ASSERT(predicate, file) \
58 _impl_CASSERT_LINE(predicate, __LINE__, file)
59#define _impl_PASTE(a, b) a##b
60#define _impl_CASSERT_LINE(predicate, line, file) \
61 typedef char _impl_PASTE(assertion_failed_##file##_, line)[2*!!(predicate)-1];
62#define static_assert(predicate, msg) \
63 COMPILE_TIME_ASSERT(predicate, msg)
64#endif
65
66#endif /*__STATIC_ASSERT_H__*/