[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] Automake migration proposal
From: |
James K. Lowden |
Subject: |
Re: [Groff] Automake migration proposal |
Date: |
Mon, 11 Aug 2014 19:27:44 -0400 |
On Mon, 11 Aug 2014 08:06:16 +0200 (CEST)
Werner LEMBERG <address@hidden> 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
- Re: [Groff] Automake migration proposal, (continued)
Re: [Groff] Automake migration proposal, Heinz-Jürgen Oertel, 2014/08/10
Re: [Groff] Automake migration proposal, Bertrand Garrigues, 2014/08/11
Re: [Groff] Automake migration proposal, Ingo Schwarze, 2014/08/11