On Mon, 11 Aug 2014 08:06:16 +0200 (CEST) Werner LEMBERG <w...@gnu.org> wrote:
> >> extern "C" const char *Version_string = "1.22.2"; > > > > extern "C" const char *Version_string; > > const char *Version_string = "1.22.2"; > > > > but I'm not sure if it's the proper way to solve this warning. > > Does > > extern "C" { > const char *Version_string = "1.22.2"; > } > > work better? It should. Stroustrup discusses the difference in 9.2.4 of The C++ Programming Language. His examples: extern "C" { int g1; // definition extern int g2; // declaration } extern "C" int g1; // declaration Although, he says, it "looks odd at first glance", it's a consequence of the fact that the first form admits other code being #included. In light of that, extern "C" const char *Version_string = "1.22.2"; is problematic because storage for the pointer hasn't been defined. My preference, though, would be extern "C" { const char Version_string[] = "1.22.2"; } unless there is a need to have Version_string point to something else. --jkl