1 // Copyright 2014 The Chromium Authors. All rights reserved.
\r
2 // Use of this source code is governed by a BSD-style license that can be
\r
3 // found in the LICENSE file.
\r
5 // This file contains macros and macro-like constructs (e.g., templates) that
\r
6 // are commonly used throughout Chromium source. (It may also contain things
\r
7 // that are closely related to things that are commonly used that belong in this
\r
10 #ifndef BASE_MACROS_H_
\r
11 #define BASE_MACROS_H_
\r
13 // The COMPILE_ASSERT macro can be used to verify that a compile time
\r
14 // expression is true. For example, you could use it to verify the
\r
15 // size of a static array:
\r
17 // COMPILE_ASSERT(ARRAYSIZE_UNSAFE(content_type_names) == CONTENT_NUM_TYPES,
\r
18 // content_type_names_incorrect_size);
\r
20 // or to make sure a struct is smaller than a certain size:
\r
22 // COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large);
\r
24 // The second argument to the macro is the name of the variable. If
\r
25 // the expression is false, most compilers will issue a warning/error
\r
26 // containing the name of the variable.
\r
28 #undef COMPILE_ASSERT
\r
29 #define COMPILE_ASSERT(expr, msg) static_assert(expr, #msg)
\r
31 #endif // BASE_MACROS_H_
\r