ie_api.h
Go to the documentation of this file.
1 // Copyright (C) 2018-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 /**
6  * @brief The macro defines a symbol import/export mechanism essential for Microsoft Windows(R) OS.
7  *
8  * @file ie_api.h
9  */
10 #pragma once
11 
12 #include "details/ie_no_copy.hpp"
13 
14 #if defined(USE_STATIC_IE) || (defined(__GNUC__) && (__GNUC__ < 4))
15 # define INFERENCE_ENGINE_API(...) extern "C" __VA_ARGS__
16 # define INFERENCE_ENGINE_API_CPP(...) __VA_ARGS__
17 # define INFERENCE_ENGINE_API_CLASS(...) __VA_ARGS__
18 # define INFERENCE_ENGINE_CDECL __attribute__((cdecl))
19 #else
20 # if defined(_WIN32)
21 # define INFERENCE_ENGINE_CDECL
22 # ifdef IMPLEMENT_INFERENCE_ENGINE_API
23 # define INFERENCE_ENGINE_API(...) extern "C" __declspec(dllexport) __VA_ARGS__ __cdecl
24 # define INFERENCE_ENGINE_API_CPP(...) __declspec(dllexport) __VA_ARGS__ __cdecl
25 # define INFERENCE_ENGINE_API_CLASS(...) __declspec(dllexport) __VA_ARGS__
26 # else
27 # define INFERENCE_ENGINE_API(...) extern "C" __declspec(dllimport) __VA_ARGS__ __cdecl
28 # define INFERENCE_ENGINE_API_CPP(...) __declspec(dllimport) __VA_ARGS__ __cdecl
29 # define INFERENCE_ENGINE_API_CLASS(...) __declspec(dllimport) __VA_ARGS__
30 # endif
31 # else
32 # define INFERENCE_ENGINE_CDECL __attribute__((cdecl))
33 # define INFERENCE_ENGINE_API(...) extern "C" __attribute__((visibility("default"))) __VA_ARGS__
34 # define INFERENCE_ENGINE_API_CPP(...) __attribute__((visibility("default"))) __VA_ARGS__
35 # define INFERENCE_ENGINE_API_CLASS(...) __attribute__((visibility("default"))) __VA_ARGS__
36 # endif
37 #endif
38 
39 #if defined(_WIN32)
40 # define INFERENCE_ENGINE_DEPRECATED(msg) __declspec(deprecated(msg))
41 #elif defined __INTEL_COMPILER
42 # define INFERENCE_ENGINE_DEPRECATED(msg) __attribute__((deprecated(msg)))
43 #elif defined(__GNUC__)
44 # define INFERENCE_ENGINE_DEPRECATED(msg) __attribute__((deprecated((msg))))
45 #else
46 # define INFERENCE_ENGINE_DEPRECATED(msg)
47 #endif
48 
49 #if defined IMPLEMENT_INFERENCE_ENGINE_API || defined IMPLEMENT_INFERENCE_ENGINE_PLUGIN
50 # define INFERENCE_ENGINE_INTERNAL(msg)
51 #else
52 # define INFERENCE_ENGINE_INTERNAL(msg) INFERENCE_ENGINE_DEPRECATED(msg)
53 #endif
54 
55 #if defined IMPLEMENT_INFERENCE_ENGINE_API || defined IMPLEMENT_INFERENCE_ENGINE_PLUGIN
56 # define INFERENCE_ENGINE_INTERNAL_CNNLAYER_CLASS(...) INFERENCE_ENGINE_API_CLASS(__VA_ARGS__)
57 #else
58 # define INFERENCE_ENGINE_INTERNAL_CNNLAYER_CLASS(...) \
59  INFERENCE_ENGINE_INTERNAL("Migrate to IR v10 and work with ngraph::Function directly. The method will be removed in 2021.1") \
60  INFERENCE_ENGINE_API_CLASS(__VA_ARGS__)
61 #endif
62 
63 // Suppress warning "-Wdeprecated-declarations" / C4996
64 #if defined(_MSC_VER)
65 # define IE_DO_PRAGMA(x) __pragma(x)
66 #elif defined(__GNUC__)
67 # define IE_DO_PRAGMA(x) _Pragma(#x)
68 #else
69 # define IE_DO_PRAGMA(x)
70 #endif
71 
72 #if defined(_MSC_VER) && !defined(__clang__)
73 # define IE_SUPPRESS_DEPRECATED_START \
74  IE_DO_PRAGMA(warning(push)) \
75  IE_DO_PRAGMA(warning(disable : 4996))
76 # define IE_SUPPRESS_DEPRECATED_END IE_DO_PRAGMA(warning(pop))
77 #elif defined(__INTEL_COMPILER)
78 # define IE_SUPPRESS_DEPRECATED_START \
79  IE_DO_PRAGMA(warning(push)) \
80  IE_DO_PRAGMA(warning(disable : 1478))
81  IE_DO_PRAGMA(warning(disable : 1786))
82 # define IE_SUPPRESS_DEPRECATED_END IE_DO_PRAGMA(warning(pop))
83 #elif defined(__clang__) || ((__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 405))
84 # define IE_SUPPRESS_DEPRECATED_START \
85  IE_DO_PRAGMA(GCC diagnostic push) \
86  IE_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
87 # define IE_SUPPRESS_DEPRECATED_END IE_DO_PRAGMA(GCC diagnostic pop)
88 #else
89 # define IE_SUPPRESS_DEPRECATED_START
90 # define IE_SUPPRESS_DEPRECATED_END
91 #endif
92 
93 #ifdef _WIN32
94 # define IE_SUPPRESS_DEPRECATED_START_WIN IE_SUPPRESS_DEPRECATED_START
95 # define IE_SUPPRESS_DEPRECATED_END_WIN IE_SUPPRESS_DEPRECATED_END
96 #else
97 # define IE_SUPPRESS_DEPRECATED_START_WIN
98 # define IE_SUPPRESS_DEPRECATED_END_WIN
99 #endif
100 
101 #ifndef ENABLE_UNICODE_PATH_SUPPORT
102 # ifdef _WIN32
103 # ifdef __INTEL_COMPILER
104 # define ENABLE_UNICODE_PATH_SUPPORT
105 # endif
106 # if defined _MSC_VER && defined _MSVC_LANG && _MSVC_LANG < 201703L
107 # define ENABLE_UNICODE_PATH_SUPPORT
108 # endif
109 # elif defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 2)) || defined(__clang__)
110 # define ENABLE_UNICODE_PATH_SUPPORT
111 # endif
112 #endif
113 
114 /**
115  * @def INFERENCE_PLUGIN_API(type)
116  * @brief Defines Inference Engine Plugin API method
117  * @param type A plugin type
118  */
119 
120 #if defined(_WIN32)
121 # ifdef IMPLEMENT_INFERENCE_ENGINE_PLUGIN
122 # define INFERENCE_PLUGIN_API(type) extern "C" __declspec(dllexport) type
123 # else
124 # define INFERENCE_PLUGIN_API(type) extern "C" type
125 # endif
126 #elif (__GNUC__ >= 4) // NOLINT
127 # ifdef IMPLEMENT_INFERENCE_ENGINE_PLUGIN
128 # define INFERENCE_PLUGIN_API(type) extern "C" __attribute__((visibility("default"))) type
129 # else
130 # define INFERENCE_PLUGIN_API(type) extern "C" type
131 # endif
132 #else
133 # define INFERENCE_PLUGIN_API(TYPE) extern "C" TYPE
134 #endif
header file for no_copy class