andrei
andrei

Reputation: 2083

C++ - deprecated conversion from string constant to ‘char*’ in 3rd-party header

I am including a couple of 3rd-party headers into my .cpp file (wrapped in extern "C" of course), and I'm getting the annoying deprecated conversion from string constant to ‘char*’ warning during compilation, even when I don't call the functions defined in the header files. Given that I cannot change the headers, is there a good way to silence/ignore these warnings or do I just have to live with them?

Upvotes: 0

Views: 2664

Answers (3)

Carl
Carl

Reputation: 44458

It would depend on your compiler. Here's what you'd do for g++:

#pragma GCC diagnostic ignored "-Wwrite-strings"
#include <files that generate the warning>
#pragma GCC diagnostic warning "-Wwrite-strings"

Upvotes: 2

justin
justin

Reputation: 104698

your compiler (GCC?) may support disabling warnings over a range of lines or sources.

of course, you should also report the bug to the vendor.

So you'd write something along these lines -- compiler specific:

#pragma PUSH COMPILER IGNORE SOME WARNING
#include <third_party_headers.h>
#pragma POP COMPILER IGNORE SOME WARNING

Upvotes: 0

Borealid
Borealid

Reputation: 98489

You could disable the warning by compiling with -Wno-write-strings.

I'm assuming this is g++ we're talking about here.

Upvotes: 1

Related Questions