Re: How to make local variable's address is 8 byte alignment?
- From: Mark Bluemel <mark_bluemel@xxxxxxxxx>
- Date: Thu, 10 Jan 2008 16:46:30 +0000
David Mathog wrote:
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.
If the OP wanted to use a general area of bytes as a place he could take a pointer into and manipulate as (for example) long or double, he may
need this sort of guarantee. Perhaps he'll tell us what he's trying to
do...
.
- Follow-Ups:
- Re: How to make local variable's address is 8 byte alignment?
- From: Pengjun Jia
- Re: How to make local variable's address is 8 byte alignment?
- From: Jack Klein
- 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
- Re: How to make local variable's address is 8 byte alignment?
- From: David Mathog
- How to make local variable's address is 8 byte alignment?
- Prev by Date: Re: function pointers
- Next by Date: Re: Programming in standard c
- 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
|