Re: New draft version of o65 file format

From: Spiro Trikaliotis (ml-cbmhackers_at_trikaliotis.net)
Date: 2005-04-01 13:27:13

Hello Uz,

* On Fri, Apr 01, 2005 at 12:45:53PM +0200 Ullrich von Bassewitz wrote:
 
> My suggestion for every C programmer is to keep a copy of the standard
> available and have a look into it.  It contains a lot of interesting
> things and debunks a whole lot of myths many C "programmers" believe:

One problem with this is that some people learned C before C89. That's
where many myths come from.

>   * Did you know that C does not require a char to have 8 bits? It does not
>     require ints to have 16, and longs to have 32 bits either.

I do. A char must have enough bits to hold all characters of the base
charset of the system, and

1 == sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)

is required.

But the statement "a char is always enough to hold a byte" should be
correct if you remember that a byte is not always an octett.

>   * Did you know that a NULL pointer must not be represented by a binary zero,
>     and that - despite this fact - a compare like
> 
>         if (p == 0) ...
> 
>     does still test p for the NULL pointer? Even
> 
>         if (p) ...
> 
>     is a correct test for the NULL pointer, even on platforms where the NULL
>     pointer is represented by something like 0x12345678.

I now. This difference might be needed for example with machines with a
segmented architecture, where a special segment might indicate a
null-pointer.

>   * Did you know that a main program declaration of
> 
>         void main (void)
> 
>     is non portable and may be refused by the compiler?

Yes, because it does not return an int.

int main(void)

must be accepted, as well as

int main(int argc, char **argv)


Everything else is non-standard.


>   * Did you know that
> 
>         char f = 5["abcdefg"];
>
>     is completely legal C?

Yes, with f == 'f' afterwards. Thats because x[y] is equivalent to *(x+y)

> It's always better to know instead of just believe. And the ISO C
> standard is the way to knowledge for C programmers.

But it's hard with pre-ANSI, C89, C90, the C++ variants which are very
similar, to always keep up with the correct standard. ;-)

BTW: I did not fail your test, did I? Where can I get my diploma? ;-)


Regards,
   Spiro.

-- 
Spiro R. Trikaliotis
http://www.trikaliotis.net/

       Message was sent through the cbm-hackers mailing list

Archive generated by hypermail pre-2.1.8.