1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MOJO_PUBLIC_C_SYSTEM_MACROS_H_
6 #define MOJO_PUBLIC_C_SYSTEM_MACROS_H_
10 // Annotate a variable indicating it's okay if it's unused.
12 // int x MOJO_ALLOW_UNUSED = ...;
14 #define MOJO_ALLOW_UNUSED __attribute__((unused))
16 #define MOJO_ALLOW_UNUSED
19 // Annotate a function indicating that the caller must examine the return value.
21 // int foo() MOJO_WARN_UNUSED_RESULT;
22 // Note that it can only be used on the prototype, and not the definition.
24 #define MOJO_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
26 #define MOJO_WARN_UNUSED_RESULT
29 // This macro is currently C++-only, but we want to use it in the C core.h.
30 // Used to assert things at compile time.
31 #if __cplusplus >= 201103L
32 #define MOJO_COMPILE_ASSERT(expr, msg) static_assert(expr, #msg)
33 #elif defined(__cplusplus)
34 namespace mojo { template <bool> struct CompileAssert {}; }
35 #define MOJO_COMPILE_ASSERT(expr, msg) \
36 typedef ::mojo::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
38 #define MOJO_COMPILE_ASSERT(expr, msg)
41 #endif // MOJO_PUBLIC_C_SYSTEM_MACROS_H_