|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I test it with char, short, int, long, float, double and struct
pointers, all return 4 bytes. Does the standard say anything about sizeof a pointer? (I didn't find it in the standard...) -- William http://williamxu.net9.org |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
William Xu wrote:
> I test it with char, short, int, long, float, double and struct > pointers, all return 4 bytes. Does the standard say anything about > sizeof a pointer? (I didn't find it in the standard...) > No, it is implementation specific. -- Ian Collins. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
William Xu wrote:
> I test it with char, short, int, long, float, double and struct > pointers, all return 4 bytes. Does the standard say anything about > sizeof a pointer? (I didn't find it in the standard...) > it's implementation defined. e.g on 32-bit machine, sizeof(ptr) may be 32 and 64-bit machine it returns 64. Road -- C FAQ: http://c-faq.com/ |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
William Xu wrote:
> I test it with char, short, int, long, float, double and struct > pointers, all return 4 bytes. Does the standard say anything about > sizeof a pointer? (I didn't find it in the standard...) No. It says that a pointer of type void * must be capable of holding any pointer value, but nothing specific is said about the sizes of pointers. Pointers to different types could be of the same or different sizes. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Road Tang <roadtang@gmail.com> writes:
> it's implementation defined. > e.g > > on 32-bit machine, sizeof(ptr) may be 32 Then, is it safe to say that sizeof(ptr) <= 32 ? > and 64-bit machine it returns 64. Similarly, sizeof(ptr) <= 64 ? -- William http://williamxu.net9.org |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
>I test it with char, short, int, long, float, double and struct > pointers, all return 4 bytes. Does the standard say anything about > sizeof a pointer? (I didn't find it in the standard...) > > -- > William Pointers of any type will have the same size because they hold the address value of memory that they point to, thus they always hold the same type of data. On standard PC's this is a 32bit address (4 bytes), but it depends on the system what the size is. |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
William Xu wrote:
> Road Tang <roadtang@gmail.com> writes: > >> it's implementation defined. >> e.g >> >> on 32-bit machine, sizeof(ptr) may be 32 > > Then, is it safe to say that sizeof(ptr) <= 32 ? No, I did't find the Standard have such rules about it. I just write that number for example. >> and 64-bit machine it returns 64. > > Similarly, sizeof(ptr) <= 64 ? > You like this apply? but I'm still not sure. ![]() -- C FAQ: http://c-faq.com/ |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
On Mon, 22 Oct 2007 14:04:59 +0530,
santosh <santosh.k83@gmail.com> wrote: > William Xu wrote: > >> I test it with char, short, int, long, float, double and struct >> pointers, all return 4 bytes. Does the standard say anything about >> sizeof a pointer? (I didn't find it in the standard...) > > No. It says that a pointer of type void * must be capable of holding any > pointer value, but nothing specific is said about the sizes of > pointers. Except, possibly, pointers to function. Martien -- | Martien Verbruggen | You can't have everything, where would you | put it? | |
|
![]() |
| Outils de la discussion | |
|
|