Re: Slightly OT: integer sizes in C program




So may we conclude that sizeof(long) depends on whether the compiler
runs in 32 or 64 bit mode rather than being an intrinsic feature
of the compiler itself?
32bit: long==4, 64bit: long==8.
Any example for 64bit: long==4? (which is what one of the OPs has said
about M$'s product)
Maybe the confusion comes from the fact that different compilers
use different default modes.


On the HP-UX and Linux compilers, I found that sizeof(long) == sizeof(void
*). So that matched your theory.

However, on OpenVMS, that didn't follow. Even with /POINTER=64, I found:

$ cc ll.c
$ link ll
$ run ll
2 short
4 int
4 long
8 long long
4 void *

$ cc /pointer=64 ll.c
$ link ll
$ run ll
2 short
4 int
4 long
8 long long
8 void *

Essentially, I think all you can assume is that sizeof(long) <=
sizeof(void*). I scanned the c99 standard looking for the clause, but
didn't spot in during my 2 minute timelimit.

I didn't try Visual C.

John


.



Relevant Pages

  • Re: fields for methods?
    ... but only by a compiler that is allowed to ... struct A {void foo();}; ... int static_instance i = 0; ... Is not possible because foo is the only member of A... ...
    (comp.programming)
  • Re: fields for methods?
    ... void A::foo{ ... but only by a compiler that is allowed to ... int static_instance i = 0; ... it totally breaks the idea of encapsulation, which is the reason a lot ...
    (comp.programming)
  • Re: Virtual Machine implementation problem, Please help me to spot the bug
    ... This is non-standard (Conceivably your compiler allows it ... tmp1 might not be correctly aligned for u32. ... void change_endian{ ... typedef unsigned int u32; ...
    (comp.lang.c)
  • Re: C Questions
    ... No prototype is given for this function, so the compiler cannot ... To prototype a function with no parameters, use void: ... %d takes an int argument, ...
    (comp.lang.c)
  • Re: The_Sage & void main()
    ... shall have a return type of type int but otherwise in all other respects ... > main may have the return type void then main may indeed have the ... If the compiler accepts void main, then you may use void main ... about whether void mainis conforming or not. ...
    (comp.lang.cpp)