Flutter Engine
The Flutter Engine
third_party
accessibility
base
compiler_specific.h
Go to the documentation of this file.
1
// Copyright 2013 The Flutter 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.
4
5
#ifndef ACCESSIBILITY_BASE_COMPILER_SPECIFIC_H_
6
#define ACCESSIBILITY_BASE_COMPILER_SPECIFIC_H_
7
8
#if !defined(__GNUC__) && !defined(__clang__) && !defined(_MSC_VER)
9
#error Unsupported compiler.
10
#endif
11
12
// Annotate a variable indicating it's ok if the variable is not used.
13
// (Typically used to silence a compiler warning when the assignment
14
// is important for some other reason.)
15
// Use like:
16
// int x = ...;
17
// BASE_ALLOW_UNUSED_LOCAL(x);
18
#define BASE_ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0
19
20
// Annotate a typedef or function indicating it's ok if it's not used.
21
// Use like:
22
// typedef Foo Bar ALLOW_UNUSED_TYPE;
23
#if defined(__GNUC__) || defined(__clang__)
24
#define BASE_ALLOW_UNUSED_TYPE __attribute__((unused))
25
#else
26
#define BASE_ALLOW_UNUSED_TYPE
27
#endif
28
29
#endif
// ACCESSIBILITY_BASE_COMPILER_SPECIFIC_H_
30
31
// Macro for hinting that an expression is likely to be false.
32
#if !defined(BASE_UNLIKELY)
33
#if defined(COMPILER_GCC) || defined(__clang__)
34
#define BASE_UNLIKELY(x) __builtin_expect(!!(x), 0)
35
#else
36
#define BASE_UNLIKELY(x) (x)
37
#endif
// defined(COMPILER_GCC)
38
#endif
// !defined(BASE_UNLIKELY)
39
40
#if !defined(BASE_LIKELY)
41
#if defined(COMPILER_GCC) || defined(__clang__)
42
#define BASE_LIKELY(x) __builtin_expect(!!(x), 1)
43
#else
44
#define BASE_LIKELY(x) (x)
45
#endif
// defined(COMPILER_GCC)
46
#endif
// !defined(BASE_LIKELY)
47
48
// Macro for telling -Wimplicit-fallthrough that a fallthrough is intentional.
49
#if defined(__clang__)
50
#define BASE_FALLTHROUGH [[clang::fallthrough]]
51
#else
52
#define BASE_FALLTHROUGH
53
#endif
Generated on Sun Jun 23 2024 21:54:57 for Flutter Engine by
1.9.4