summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/include/gnuradio/attributes.h
blob: 4690dff68d58468100c5f9982085b19e67afd05c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
 * Copyright 2010 Free Software Foundation, Inc.
 *
 * This file is part of GNU Radio
 *
 * GNU Radio is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 *
 * GNU Radio is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GNU Radio; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street,
 * Boston, MA 02110-1301, USA.
 */

#ifndef INCLUDED_GNURADIO_ATTRIBUTES_H
#define INCLUDED_GNURADIO_ATTRIBUTES_H

////////////////////////////////////////////////////////////////////////
// Cross-platform attribute macros
////////////////////////////////////////////////////////////////////////
#if defined(__clang__) && (!defined(_MSC_VER))
// AppleClang also defines __GNUC__, so do this check first.  These
// will probably be the same as for __GNUC__, but let's keep them
// separate just to be safe.
#define __GR_ATTR_ALIGNED(x) __attribute__((aligned(x)))
#define __GR_ATTR_UNUSED __attribute__((unused))
#define __GR_ATTR_INLINE __attribute__((always_inline))
#define __GR_ATTR_DEPRECATED __attribute__((deprecated))
#define __GR_ATTR_EXPORT __attribute__((visibility("default")))
#define __GR_ATTR_IMPORT __attribute__((visibility("default")))
#elif defined __GNUC__
#define __GR_ATTR_ALIGNED(x) __attribute__((aligned(x)))
#define __GR_ATTR_UNUSED __attribute__((unused))
#define __GR_ATTR_INLINE __attribute__((always_inline))
#define __GR_ATTR_DEPRECATED __attribute__((deprecated))
#if __GNUC__ >= 4
#define __GR_ATTR_EXPORT __attribute__((visibility("default")))
#define __GR_ATTR_IMPORT __attribute__((visibility("default")))
#else
#define __GR_ATTR_EXPORT
#define __GR_ATTR_IMPORT
#endif
#elif _MSC_VER
#define __GR_ATTR_ALIGNED(x) __declspec(align(x))
#define __GR_ATTR_UNUSED
#define __GR_ATTR_INLINE __forceinline
#define __GR_ATTR_DEPRECATED __declspec(deprecated)
#define __GR_ATTR_EXPORT __declspec(dllexport)
#define __GR_ATTR_IMPORT __declspec(dllimport)
#else
#define __GR_ATTR_ALIGNED(x)
#define __GR_ATTR_UNUSED
#define __GR_ATTR_INLINE
#define __GR_ATTR_DEPRECATED
#define __GR_ATTR_EXPORT
#define __GR_ATTR_IMPORT
#endif

////////////////////////////////////////////////////////////////////////
// define inline when building C
////////////////////////////////////////////////////////////////////////
#if defined(_MSC_VER) && !defined(__cplusplus) && !defined(inline)
#define inline __inline
#endif

////////////////////////////////////////////////////////////////////////
// suppress warnings
////////////////////////////////////////////////////////////////////////
#ifdef _MSC_VER
#pragma warning(disable : 4251) // class 'A<T>' needs to have dll-interface to be used by
                                // clients of class 'B'
#pragma warning(disable : 4275) // non dll-interface class ... used as base for
                                // dll-interface class ...
#pragma warning( \
    disable : 4244) // conversion from 'double' to 'float', possible loss of data
#pragma warning(disable : 4305) // 'initializing' : truncation from 'double' to 'float'
#pragma warning(disable : 4290) // C++ exception specification ignored except to indicate
                                // a function is not __declspec(nothrow)
#endif

////////////////////////////////////////////////////////////////////////
// implement cross-compiler VLA macros
////////////////////////////////////////////////////////////////////////
#ifdef _MSC_VER
#define __GR_VLA(TYPE, buf, size) TYPE* buf = (TYPE*)alloca(sizeof(TYPE) * (size))
#else
#define __GR_VLA(TYPE, buf, size) TYPE buf[size]
#endif

#endif /* INCLUDED_GNURADIO_ATTRIBUTES_H */