Re: Order of variables in specific sections when enabling optimization in gcc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Please keep Freddie in the recipents since it's possible he haven't subscribed.

On 2019-03-07 13:58 +0100, Matthias Pfaller wrote:
> On 03/07/2019 01:16 PM, Freddie Chopin wrote:
> > No worries, it won't optimize them away, there's also a header where
> > these variables are declared with `extern ...` (omitted that in the
> > example, as this doesn't change anything) and all of them will be used
> > in the project. I'm just concerned about their order.
> 
> Just put them into a structure. If you need to maintain the old names,
> you can always use #define.
> 
> struct {
> 	int a;
> 	int b;
> 	int c;
> } globals;

I think we'll need "extern volatile struct".  The access to one volatile struct
is kept even with -O3.

> #define a	global.a
> #define b	global.b
> #define c	global.c

Anyway, using linker script is the right way to do this and I recommend to do
so.
-- 
Xi Ruoyao <xry111@xxxxxxxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux