aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
inline.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2025 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
58#ifndef GUM_INLINE_H
59#define GUM_INLINE_H
60
61#ifndef DOXYGEN_SHOULD_SKIP_THIS
62
63# ifndef GUM_NO_INLINE
64
65# define INLINE inline
66
67// ENFORCED_INLINE is a stronger version of the inline, using _forceinline_ on
68// MSVC, but it still doesn't use GCC's always_inline. This is useful in
69// (common) situations where MSVC needs forceinline but GCC is still doing fine
70// with just inline. (from eigen library)
71# if (defined _MSC_VER) || (defined _INTEL_COMPILER_)
72# define ENFORCED_INLINE __forceinline
73# else
74# define ENFORCED_INLINE inline
75# endif
76
77// ALWAYS_INLINE is the strongest, it has the effect of making the function
78// inline and adding every possible attribute to maximize inlining. This should
79// only be used when really necessary: in particular, it uses
80// __attribute__((always_inline)) on GCC, which most of the time is useless and
81// can severely harm compile times.
82// @warning with the always_inline attribute, gcc 3.4.x reports the following
83// compilation error:
84// Eval.h:91: sorry, unimplemented: inlining failed in call to '...' :
85// function body not available (from eigen library)
86# if GNUC_AT_LEAST(4, 0)
87# define ALWAYS_INLINE __attribute__((always_inline)) inline
88# else
89# define ALWAYS_INLINE ENFORCED_INLINE
90# endif
91
92# if (defined __GNUC__)
93# define NO_INLINE __attribute__((noinline))
94# elif (defined _MSC_VER)
95# define NEVER_INLINE _declspec_(noinline)
96# else
97# define NEVER_INLINE
98# endif
99# else // GUM_NO_INLINE
100# define INLINE
101# define STRONG_INLINE
102# define ALWAYS_INLINE
103# define NEVER_INLINE
104# endif /* GUM_NO_INLINE */
105
106#endif /* DOXYGEN_SHOULD_SKIP_THIS */
107
108#endif /* GUM_INLINE_H */