This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: gcc gets in the way of writing C that is also C++ wrt const
- From: Andrew Haley <aph at redhat dot com>
- To: Jay K <jay dot krell at cornell dot edu>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Tue, 21 Jul 2009 15:08:17 +0100
- Subject: Re: gcc gets in the way of writing C that is also C++ wrt const
- References: <COL101-W181AA5B1132B355C9BCF06E61A0@phx.gbl>
Jay K wrote:
> I was pointed to:
>
> http://david.tribble.com/text/cdiffs.htm#C99-const-linkage
>
>
> which recommends exactly what I'd like to do:
>
>
>>> The recommended practice is therefore to define constants with an explicit static or extern specifier
>
>
> C:\>type 1.c
> extern const int b = 1;
>
>
> C:\>gcc -c 1.c
> 1.c:1: warning: `b' initialized and declared `extern'
>
>
> Why the warning?
Because it doesn't make much sense for C.
Try -Wc++-compat
Andrew.