GNU Radio Manual and C++ API Reference  3.8.1.0
The Free & Open Software Radio Ecosystem
attributes.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010 Free Software Foundation, Inc.
3  *
4  * This file is part of GNU Radio
5  *
6  * GNU Radio is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3, or (at your option)
9  * any later version.
10  *
11  * GNU Radio 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
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GNU Radio; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef INCLUDED_GNURADIO_ATTRIBUTES_H
23 #define INCLUDED_GNURADIO_ATTRIBUTES_H
24 
25 ////////////////////////////////////////////////////////////////////////
26 // Cross-platform attribute macros
27 ////////////////////////////////////////////////////////////////////////
28 #if defined __GNUC__
29 #define __GR_ATTR_ALIGNED(x) __attribute__((aligned(x)))
30 #define __GR_ATTR_UNUSED __attribute__((unused))
31 #define __GR_ATTR_INLINE __attribute__((always_inline))
32 #define __GR_ATTR_DEPRECATED __attribute__((deprecated))
33 #if __GNUC__ >= 4
34 #define __GR_ATTR_EXPORT __attribute__((visibility("default")))
35 #define __GR_ATTR_IMPORT __attribute__((visibility("default")))
36 #else
37 #define __GR_ATTR_EXPORT
38 #define __GR_ATTR_IMPORT
39 #endif
40 #elif defined __clang__
41 #define __GR_ATTR_ALIGNED(x) __attribute__((aligned(x)))
42 #define __GR_ATTR_UNUSED __attribute__((unused))
43 #define __GR_ATTR_INLINE __attribute__((always_inline))
44 #define __GR_ATTR_DEPRECATED __attribute__((deprecated))
45 #define __GR_ATTR_EXPORT __attribute__((visibility("default")))
46 #define __GR_ATTR_IMPORT __attribute__((visibility("default")))
47 #elif _MSC_VER
48 #define __GR_ATTR_ALIGNED(x) __declspec(align(x))
49 #define __GR_ATTR_UNUSED
50 #define __GR_ATTR_INLINE __forceinline
51 #define __GR_ATTR_DEPRECATED __declspec(deprecated)
52 #define __GR_ATTR_EXPORT __declspec(dllexport)
53 #define __GR_ATTR_IMPORT __declspec(dllimport)
54 #else
55 #define __GR_ATTR_ALIGNED(x)
56 #define __GR_ATTR_UNUSED
57 #define __GR_ATTR_INLINE
58 #define __GR_ATTR_DEPRECATED
59 #define __GR_ATTR_EXPORT
60 #define __GR_ATTR_IMPORT
61 #endif
62 
63 ////////////////////////////////////////////////////////////////////////
64 // define inline when building C
65 ////////////////////////////////////////////////////////////////////////
66 #if defined(_MSC_VER) && !defined(__cplusplus) && !defined(inline)
67 #define inline __inline
68 #endif
69 
70 ////////////////////////////////////////////////////////////////////////
71 // suppress warnings
72 ////////////////////////////////////////////////////////////////////////
73 #ifdef _MSC_VER
74 #pragma warning(disable : 4251) // class 'A<T>' needs to have dll-interface to be used by
75  // clients of class 'B'
76 #pragma warning(disable : 4275) // non dll-interface class ... used as base for
77  // dll-interface class ...
78 #pragma warning( \
79  disable : 4244) // conversion from 'double' to 'float', possible loss of data
80 #pragma warning(disable : 4305) // 'initializing' : truncation from 'double' to 'float'
81 #pragma warning(disable : 4290) // C++ exception specification ignored except to indicate
82  // a function is not __declspec(nothrow)
83 #endif
84 
85 ////////////////////////////////////////////////////////////////////////
86 // implement cross-compiler VLA macros
87 ////////////////////////////////////////////////////////////////////////
88 #ifdef _MSC_VER
89 #define __GR_VLA(TYPE, buf, size) TYPE* buf = (TYPE*)alloca(sizeof(TYPE) * (size))
90 #else
91 #define __GR_VLA(TYPE, buf, size) TYPE buf[size]
92 #endif
93 
94 #endif /* INCLUDED_GNURADIO_ATTRIBUTES_H */