Re: How to make local variable's address is 8 byte alignment?
- From: David Mathog <mathog@xxxxxxxxxxx>
- Date: Thu, 10 Jan 2008 08:29:26 -0800
Pengjun Jia wrote:
HP-UX 11.23, HP aC++ B3910B A.03.63
Here is a samples.
bjhp1 /nfs/users/pjia>cat tt.c
#include <stdlib.h>
int main()
{
int i =10 ;
char p[1024] ="" ;
printf("%p, %p\n", &i, p) ;
return 0 ;
}
Well, you could always allocate an extra 8 bytes for the array p
and then use a pointer to the first position in that array which is on an 8 byte alignment instead of p itself.
I don't see the point though for this example. With integers and such
it will likely make a difference if the variable is not properly aligned, but the compiler will generally take care of that for you.
Regards,
David Mathog
.
- Follow-Ups:
- Re: How to make local variable's address is 8 byte alignment?
- From: Mark Bluemel
- Re: How to make local variable's address is 8 byte alignment?
- References:
- How to make local variable's address is 8 byte alignment?
- From: Pengjun Jia
- How to make local variable's address is 8 byte alignment?
- Prev by Date: Re: Does this code executes properly ??????????
- Next by Date: Re: function pointers
- Previous by thread: Re: How to make local variable's address is 8 byte alignment?
- Next by thread: Re: How to make local variable's address is 8 byte alignment?
- Index(es):
Relevant Pages
|