Skip to content

Commit ae55818

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

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

sensor_msgs/include/sensor_msgs/image_encodings.hpp

+27
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,25 @@ const std::regex cv_type_regex("(8|16|32|64)(U|S|F)C([0-9]*)");
122122
// Utility functions for inspecting an encoding string
123123
static inline bool isColor(const std::string & encoding)
124124
{
125+
#ifdef _MSC_VER
126+
#pragma warning(push)
127+
#pragma warning(disable : 4996)
128+
#else
125129
#pragma GCC diagnostic push
126130
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
131+
#endif
127132
return encoding == RGB8 || encoding == BGR8 ||
128133
encoding == RGBA8 || encoding == BGRA8 ||
129134
encoding == RGB16 || encoding == BGR16 ||
130135
encoding == RGBA16 || encoding == BGRA16 ||
131136
encoding == YUV422 || encoding == YUV422_YUY2 ||
132137
encoding == UYVY || encoding == YUYV ||
133138
encoding == NV21 || encoding == NV24;
139+
#ifdef _MSC_VER
140+
#pragma warning(pop)
141+
#else
134142
#pragma GCC diagnostic pop
143+
#endif
135144
}
136145

137146
static inline bool isMono(const std::string & encoding)
@@ -194,8 +203,13 @@ static inline int numChannels(const std::string & encoding)
194203
return (m[3] == "") ? 1 : std::atoi(m[3].str().c_str());
195204
}
196205

206+
#ifdef _MSC_VER
207+
#pragma warning(push)
208+
#pragma warning(disable : 4996)
209+
#else
197210
#pragma GCC diagnostic push
198211
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
212+
#endif
199213
if (encoding == YUV422 ||
200214
encoding == YUV422_YUY2 ||
201215
encoding == UYVY ||
@@ -205,7 +219,11 @@ static inline int numChannels(const std::string & encoding)
205219
{
206220
return 2;
207221
}
222+
#ifdef _MSC_VER
223+
#pragma warning(pop)
224+
#else
208225
#pragma GCC diagnostic pop
226+
#endif
209227

210228
throw std::runtime_error("Unknown encoding " + encoding);
211229
return -1;
@@ -249,8 +267,13 @@ static inline int bitDepth(const std::string & encoding)
249267
return std::atoi(m[0].str().c_str());
250268
}
251269

270+
#ifdef _MSC_VER
271+
#pragma warning(push)
272+
#pragma warning(disable : 4996)
273+
#else
252274
#pragma GCC diagnostic push
253275
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
276+
#endif
254277
if (encoding == YUV422 ||
255278
encoding == YUV422_YUY2 ||
256279
encoding == UYVY ||
@@ -260,7 +283,11 @@ static inline int bitDepth(const std::string & encoding)
260283
{
261284
return 8;
262285
}
286+
#ifdef _MSC_VER
287+
#pragma warning(pop)
288+
#else
263289
#pragma GCC diagnostic pop
290+
#endif
264291

265292
throw std::runtime_error("Unknown encoding " + encoding);
266293
return -1;

0 commit comments

Comments
 (0)