Re: Signed only index?



On Fri, 11 Jan 2008 13:55:40 -0800, Ben Pfaff <blp@xxxxxxxxxxxxxxx>
wrote:

"Malcolm McLean" <regniztar@xxxxxxxxxxxxxx> writes:

"Walter Roberson" <roberson@xxxxxxxxxxxxxxxxxx> wrote in message
Malcolm McLean <regniztar@xxxxxxxxxxxxxx> wrote:

Almost certainly the bytes at the location immediately before the
array "a"
will be 0x00000001.

Did I miss some evidence that on Vijay's machine,
int is 32 bits rather than (say) 16 ?

Yes. Vijay is posting to Usenet, which implies that he is using a
fairly modern desktop computer.

I've seen a surprising number of posters here who appear to be
using antique compilers for DOS, such as Turbo C 2.0, which had
16-bit int.

The C Standard places no restrictions on any relationship between the
host platform and the target platform. Embedded programmers are
thankful for this.

There is no reason whatsoever to assume that because someone posts a
message to Usenet from one platform that they are using a compiler
that targets that same platform. They could well be targeting another
platform, i.e., cross-compiling.

One of numerous examples is the TI Code Composer compiler (see [1] for
another example), which runs on Windows XP and Windows Vista, and
supports cross compilation for the C5501 DSP, which defines the
following:

CHAR_BIT = 16
sizeof(char) = 1 /* by definition in C */
sizeof(short) = 1
sizeof(int) = 1
sizeof(long) = 2

It should be noted that the C5501 is Big Endian.

And, thankfully, all of this is acceptable as far as the C Standard is
concerned.

Regards
--
jay

[1] The Microchip C30 compiler, for some targets, defines the
following:

CHAR_BIT = 8
sizeof(char) = 1 /* by definition in C */
sizeof(short) = 2
sizeof(int) = 2
sizeof(long) = 4

.



Relevant Pages

  • Re: interesting use of NEXT SENTENCE vs. CONTINUE
    ... These days I don't do compiler maintenance, but I HAVE done in the past, so ... You had a chance to point out how adherence to the standard can improve ... >> compile it WITH MINOR MODIFICATIONS for a specific platform. ... > platform-specific extension to COBOL ...
    (comp.lang.cobol)
  • Re: interesting use of NEXT SENTENCE vs. CONTINUE
    ... I DID think any old compiler would be able to ... > compile it WITH MINOR MODIFICATIONS for a specific platform. ... > not going to go to the Standard to see what SHOULD work. ... If you write your COBOL code avoiding the things that are marked as ...
    (comp.lang.cobol)
  • Re: Standard Ada Preprocessor
    ... because Ada cannot deal with the portability issues. ... > you are interfacing directly to some special-purpose hardware. ... by their nature not compiler ... one platform you get 3 members back, and on another you get 5, ...
    (comp.lang.ada)
  • Re: C portability is a myth
    ... > solicitation for the availability of a compiler for a given platform. ... People frequently talk about porting applications where no ... Yet further down you say the Java standard ports. ...
    (comp.lang.c)
  • Re: C portability is a myth
    ... > solicitation for the availability of a compiler for a given platform. ... If the source is pure Standard C ... can be successfully ported to all implementations. ...
    (comp.lang.c)