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 
23 #ifdef IMPLEMENT_INFERENCE_ENGINE_API
24 #define INFERENCE_ENGINE_API(...) extern "C" __declspec(dllexport) __VA_ARGS__ __cdecl
25 #define INFERENCE_ENGINE_API_CPP(...) __declspec(dllexport) __VA_ARGS__ __cdecl
26 #define INFERENCE_ENGINE_API_CLASS(...) __declspec(dllexport) __VA_ARGS__
27 #else
28 #define INFERENCE_ENGINE_API(...) extern "C" __declspec(dllimport) __VA_ARGS__ __cdecl
29 #define INFERENCE_ENGINE_API_CPP(...) __declspec(dllimport) __VA_ARGS__ __cdecl
30 #define INFERENCE_ENGINE_API_CLASS(...) __declspec(dllimport) __VA_ARGS__
31 #endif
32 #else
33 #define INFERENCE_ENGINE_CDECL __attribute__((cdecl))
34 #define INFERENCE_ENGINE_API(...) extern "C" __attribute__((visibility("default"))) __VA_ARGS__
35 #define INFERENCE_ENGINE_API_CPP(...) __attribute__((visibility("default"))) __VA_ARGS__
36 #define INFERENCE_ENGINE_API_CLASS(...) __attribute__((visibility("default"))) __VA_ARGS__
37 #endif
38 #endif
39 
40 #if defined(_WIN32)
41 #define INFERENCE_ENGINE_DEPRECATED(msg) __declspec(deprecated(msg))
42 #elif defined __INTEL_COMPILER
43 #define INFERENCE_ENGINE_DEPRECATED(msg) __attribute__((deprecated(msg)))
44 #elif defined(__GNUC__)
45 #define INFERENCE_ENGINE_DEPRECATED(msg) __attribute__((deprecated((msg))))
46 #else
47 #define INFERENCE_ENGINE_DEPRECATED(msg)
48 #endif
49 
50 #define INFERENCE_ENGINE_NN_BUILDER_DEPRECATED \
51  INFERENCE_ENGINE_DEPRECATED("Use ngraph API. NN Builder API will be removed in 2020.4")
52 #define INFERENCE_ENGINE_NN_BUILDER_API_CLASS(...) \
53  INFERENCE_ENGINE_NN_BUILDER_DEPRECATED \
54  INFERENCE_ENGINE_API_CLASS(__VA_ARGS__)
55 
56 #if defined IMPLEMENT_INFERENCE_ENGINE_API || defined IMPLEMENT_INFERENCE_ENGINE_PLUGIN
57 # define INFERENCE_ENGINE_INTERNAL(msg)
58 #else
59 # define INFERENCE_ENGINE_INTERNAL(msg) INFERENCE_ENGINE_DEPRECATED(msg)
60 #endif
61 
62 #if defined IMPLEMENT_INFERENCE_ENGINE_API || defined IMPLEMENT_INFERENCE_ENGINE_PLUGIN
63 # define INFERENCE_ENGINE_INTERNAL_CNNLAYER_CLASS(...) INFERENCE_ENGINE_API_CLASS(__VA_ARGS__)
64 #else
65 # define INFERENCE_ENGINE_INTERNAL_CNNLAYER_CLASS(...) \
66  INFERENCE_ENGINE_INTERNAL("Migrate to IR v10 and work with ngraph::Function directly. The method will be removed in 2021.1") \
67  INFERENCE_ENGINE_API_CLASS(__VA_ARGS__)
68 #endif
69 
70 // Suppress warning "-Wdeprecated-declarations" / C4996
71 #if defined(_MSC_VER)
72 #define IE_DO_PRAGMA(x) __pragma(x)
73 #elif defined(__GNUC__)
74 #define IE_DO_PRAGMA(x) _Pragma(#x)
75 #else
76 #define IE_DO_PRAGMA(x)
77 #endif
78 
79 #if defined(_MSC_VER) && !defined(__clang__)
80 #define IE_SUPPRESS_DEPRECATED_START \
81  IE_DO_PRAGMA(warning(push)) \
82  IE_DO_PRAGMA(warning(disable : 4996))
83 #define IE_SUPPRESS_DEPRECATED_END IE_DO_PRAGMA(warning(pop))
84 #elif defined(__INTEL_COMPILER)
85 #define IE_SUPPRESS_DEPRECATED_START \
86  IE_DO_PRAGMA(warning(push)) \
87  IE_DO_PRAGMA(warning(disable : 1478))
88  IE_DO_PRAGMA(warning(disable : 1786))
89 #define IE_SUPPRESS_DEPRECATED_END IE_DO_PRAGMA(warning(pop))
90 #elif defined(__clang__) || ((__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 405))
91 #define IE_SUPPRESS_DEPRECATED_START \
92  IE_DO_PRAGMA(GCC diagnostic push) \
93  IE_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
94 #define IE_SUPPRESS_DEPRECATED_END IE_DO_PRAGMA(GCC diagnostic pop)
95 #else
96 #define IE_SUPPRESS_DEPRECATED_START
97 #define IE_SUPPRESS_DEPRECATED_END
98 #endif
99 
100 #ifdef _WIN32
101 # define IE_SUPPRESS_DEPRECATED_START_WIN IE_SUPPRESS_DEPRECATED_START
102 # define IE_SUPPRESS_DEPRECATED_END_WIN IE_SUPPRESS_DEPRECATED_END
103 #else
104 # define IE_SUPPRESS_DEPRECATED_START_WIN
105 # define IE_SUPPRESS_DEPRECATED_END_WIN
106 #endif
107 
108 #ifndef ENABLE_UNICODE_PATH_SUPPORT
109 # ifdef _WIN32
110 # ifdef __INTEL_COMPILER
111 # define ENABLE_UNICODE_PATH_SUPPORT
112 # endif
113 # if defined _MSC_VER && defined _MSVC_LANG && _MSVC_LANG < 201703L
114 # define ENABLE_UNICODE_PATH_SUPPORT
115 # endif
116 # elif defined(__GNUC__) && (__GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ > 2)) || defined(__clang__)
117 # define ENABLE_UNICODE_PATH_SUPPORT
118 # endif
119 #endif
header file for no_copy class