Fix getauxval error at qemu
[platform/upstream/glib.git] / glib / glib-typeof.h
1 /* GLIB - Library of useful routines for C programming
2  * Copyright (C) 2021  Iain Lane, Xavier Claessens
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef __GLIB_TYPEOF_H__
21 #define __GLIB_TYPEOF_H__
22
23 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
24 #error "Only <glib.h> can be included directly."
25 #endif
26
27 #include <glib/gversionmacros.h>
28
29 /*
30  * We can only use __typeof__ on GCC >= 4.8, and not when compiling C++. Since
31  * __typeof__ is used in a few places in GLib, provide a pre-processor symbol
32  * to factor the check out from callers.
33  *
34  * This symbol is private.
35  */
36 #undef glib_typeof
37 #if !G_CXX_STD_CHECK_VERSION (11) && \
38     (G_GNUC_CHECK_VERSION(4, 8) || defined(__clang__))
39 #define glib_typeof(t) __typeof__ (t)
40 #elif G_CXX_STD_CHECK_VERSION (11) && \
41       GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68
42 /* C++11 decltype() is close enough for our usage */
43 #include <type_traits>
44 #define glib_typeof(t) typename std::remove_reference<decltype (t)>::type
45 #endif
46
47 #endif /* __GLIB_TYPEOF_H__ */