Skip to content

Commit 9e56161

Browse files
ignore deprecation warning inside the encoding header on Windows
Signed-off-by: Christian Rauch <[email protected]>
1 parent 843d011 commit 9e56161

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

sensor_msgs/include/sensor_msgs/image_encodings.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,13 @@ const std::regex cv_type_regex("(8|16|32|64)(U|S|F)C([0-9]*)");
123123
// Utility functions for inspecting an encoding string
124124
static inline bool isColor(const std::string & encoding)
125125
{
126+
#ifdef _MSC_VER
127+
#pragma warning(push)
128+
#pragma warning(disable : 4996)
129+
#else
126130
#pragma GCC diagnostic push
127131
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
132+
#endif
128133
return encoding == RGB8 || encoding == BGR8 ||
129134
encoding == RGBA8 || encoding == BGRA8 ||
130135
encoding == RGB16 || encoding == BGR16 ||
@@ -133,7 +138,11 @@ static inline bool isColor(const std::string & encoding)
133138
encoding == UYVY || encoding == YUYV ||
134139
encoding == NV12 || encoding == NV21 ||
135140
encoding == NV24;
141+
#ifdef _MSC_VER
142+
#pragma warning(pop)
143+
#else
136144
#pragma GCC diagnostic pop
145+
#endif
137146
}
138147

139148
static inline bool isMono(const std::string & encoding)
@@ -196,8 +205,13 @@ static inline int numChannels(const std::string & encoding)
196205
return (m[3] == "") ? 1 : std::atoi(m[3].str().c_str());
197206
}
198207

208+
#ifdef _MSC_VER
209+
#pragma warning(push)
210+
#pragma warning(disable : 4996)
211+
#else
199212
#pragma GCC diagnostic push
200213
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
214+
#endif
201215
if (encoding == YUV422 ||
202216
encoding == YUV422_YUY2 ||
203217
encoding == UYVY ||
@@ -208,7 +222,11 @@ static inline int numChannels(const std::string & encoding)
208222
{
209223
return 2;
210224
}
225+
#ifdef _MSC_VER
226+
#pragma warning(pop)
227+
#else
211228
#pragma GCC diagnostic pop
229+
#endif
212230

213231
throw std::runtime_error("Unknown encoding " + encoding);
214232
return -1;
@@ -252,8 +270,13 @@ static inline int bitDepth(const std::string & encoding)
252270
return std::atoi(m[0].str().c_str());
253271
}
254272

273+
#ifdef _MSC_VER
274+
#pragma warning(push)
275+
#pragma warning(disable : 4996)
276+
#else
255277
#pragma GCC diagnostic push
256278
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
279+
#endif
257280
if (encoding == YUV422 ||
258281
encoding == YUV422_YUY2 ||
259282
encoding == UYVY ||
@@ -264,7 +287,11 @@ static inline int bitDepth(const std::string & encoding)
264287
{
265288
return 8;
266289
}
290+
#ifdef _MSC_VER
291+
#pragma warning(pop)
292+
#else
267293
#pragma GCC diagnostic pop
294+
#endif
268295

269296
throw std::runtime_error("Unknown encoding " + encoding);
270297
return -1;

0 commit comments

Comments
 (0)