Re: [LAD] G++ trouble

From: Kjetil Matheussen <k.s.matheussen@email-addr-hidden>
Date: Mon Nov 16 2020 - 14:10:55 EET

On Mon, Nov 16, 2020 at 12:59 PM Roman Sommer <roman.sommer@fau.de> wrote:
>
> Kjetil Matheussen <k.s.matheussen@gmail.com> writes:
> >
> > Yeah, I just read this: https://gcc.gnu.org/gcc-10/porting_to.html
> >
> > "
> >
> > C language issues
> >
> > Default to -fno-common
> >
> > A common mistake in C is omitting extern when declaring a global
> > variable in a header file. If the header is included by several files
> > it results in multiple definitions of the same variable. In previous
> > GCC versions this error is ignored. GCC 10 defaults to -fno-common,
> > which means a linker error will now be reported. To fix this, use
> > extern in header files when declaring global variables, and ensure
> > each global is defined in exactly one C file. If tentative definitions
> > of particular variables need to be placed in a common block,
> > __attribute__((__common__)) can be used to force that behavior even in
> > code compiled without -fcommon. As a workaround, legacy C code where
> > all tentative definitions should be placed into a common block can be
> > compiled with -fcommon.
> >
> > int x; // tentative definition - avoid in header files
> >
> > extern int y; // correct declaration in a header file
> > "
> >
> >
> > Guess that could explain it.
>
> Hm? Why would that explain this behaviour?
> It seems to me Fons already (correctly) uses "extern" in his header

Guess you're right. I didn't read the posts very thoroughly. That's
also why I wrote "could' and not "would".
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
https://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Tue Nov 17 04:15:02 2020

This archive was generated by hypermail 2.1.8 : Tue Nov 17 2020 - 04:15:02 EET