Re: Question about unaligned pointer

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

 



On Wed, 19 Jan 2022, Bin.Cheng wrote:

> > Sure, just add a new type with non-standard alignment. Instead of
> > 'int *p' you can write e.g.
> >
> >     typedef int i32u __attribute__((aligned(1)));
> >     i32u *p;
> >
> Hi Alexander,
> Thanks very much for helping.  This works.
> However, I wonder what the difference is between typedef and the following code?
> 
> int __attribute__((aligned(1))) *p;

Here the attribute applies to the thing being declared, i.e. the variable p, not
the type it points to. You can verify this by e.g. printing __alignof(p) and
__alignof(*p).

Alexander



[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