From: Marc Espie <espie@quatramaran.ens.fr>
To: torvalds@transmeta.com
Cc: gcc@gcc.gnu.org
Subject: Re: GCC headers and DJGPP port (OT)
Date: Sun, 23 Jul 2000 07:12:00 -0000 [thread overview]
Message-ID: <200007231412.QAA10673@quatramaran.ens.fr> (raw)
In-Reply-To: <Pine.LNX.4.10.10007222131230.1315-100000@penguin.transmeta.com>
In article < Pine.LNX.4.10.10007222131230.1315-100000@penguin.transmeta.com > you write:
>And C++ made the ANSI-C-approved "((void *)0)" define illegal for some
>reason that I still haven't quite grasped. Gcc used to have the "don't
>complain" extension for some time, and now we've moved to "__null". What
>were the issues, just out of morbid curiosity?
C type system is brain-dead.
C++ type system is complicated, but at least, it offers some safety.
Specifically, conversions that increase knowledge about a pointer are
safe, so that you may safely pass an 'int *' to a function that takes a
'void *'.
The reverse is not true, for obvious reasons: you're recreating information
about a type that you don't have.
So, char *p = malloc(15); is invalid in C++, you must put the cast.
(In fact, you will rather use char *p = new char[15] in C++)
Defining NULL to (void *)0 does not work: char *p = NULL; is then illegal.
...and you want a pointer type for NULL so that you will be able to
distinguish f(0) from f(NULL)...
It's C that is completely broken here.
Historically, void is a C++ invention. I don't know what the guys who brought
void to C were thinking (as in, completely clueless). This is one of the
very few cases where C code is not valid C++ code...
Side-note: C's NULL definition is fuzzy enough that var args functions that
want to use NULL as a delineating, null pointer argument can't. For
portability, the logical null pointer in C, when you are not in a typed
context, is (void *)0.
next prev parent reply other threads:[~2000-07-23 7:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200007230426.VAA26089@neosilicon.transmeta.com>
2000-07-22 21:33 ` Linus Torvalds
2000-07-23 6:19 ` Oleg Zabluda
2000-07-23 7:12 ` Marc Espie [this message]
2000-07-23 12:04 ` Linus Torvalds
2000-07-23 16:50 ` Marc Espie
2000-07-23 19:09 ` Alexandre Oliva
2000-07-23 11:50 Phil Edwards
2000-07-23 12:13 ` Linus Torvalds
2000-07-23 13:45 ` Akbar A.
2000-07-23 12:41 Anjul Srivastava
2000-07-23 12:51 ` Mark Mitchell
2000-07-23 13:30 Mike Stump
2000-07-23 14:04 Mike Stump
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200007231412.QAA10673@quatramaran.ens.fr \
--to=espie@quatramaran.ens.fr \
--cc=gcc@gcc.gnu.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).