comp.lang.ada
 help / color / mirror / Atom feed
From: Dave Thompson <david.thompson1@worldnet.att.net>
Subject: Re: private types
Date: Mon, 27 Mar 2006 04:07:46 GMT
Date: 2006-03-27T04:07:46+00:00	[thread overview]
Message-ID: <8cb922hgoa60qejbtm7a44uejgdtrlpajm@4ax.com> (raw)
In-Reply-To: pan.2006.03.19.20.38.52.244674@linuxchip.demon.co.uk.uk.uk

--
On Sun, 19 Mar 2006 20:43:42 GMT, "Dr. Adrian Wrigley"
<amtw@linuxchip.demon.co.uk.uk.uk> wrote:

> On Sun, 19 Mar 2006 20:20:52 +0100, Martin Krischik wrote:
(C++ null pointers not all-bits-zero, also true of C)
> > Super! And how many (in %) of C++ programmer actually know that. By guess is
> > 0.1%. And indeed I is the main problem: Only a very few C/C++ programmers
> > actually master the language. 
> 
Languages, or either language. C++ is not C much as Ada is not Pascal.

> It is (or was) quite a common interview question, to see if
> C (and C++) programmers know their subject properly.  As you
> say, Robert, most don't.
> 
I don't know how common it is on interviews, having neither attended
nor given any for quite some time. It is several FAQs on comp.lang.c.

> A related topic is the issue of pointer representation, which
> (IIRC) says that pointers to char (any kind) and void have to be
> the same.  Pointers to functions have to be the same.  But all

Pointers to char and void the same, yes. Separately pointers to all
structs, and to all unions; this allows using them for 'incomplete'
types, almost (not fully) like Ada private.

Pointers to functions, not completely. Pointers to differently
prototyped functions are different types, and calling a function
through a wrong-type pointer is Undefined Behavior (= erroneous = not
required to be caught/diagnosed or to do anything even remotely
reasonable). However, any function that is or could have been defined
in nonprototype aka K&R1 aka oldstyle form must be callable using a
(K&R1-style) 'pointer to function of unspecified arguments'. In
practice this means that most systems use a compatible calling
sequence for at least all nonvarargs functions, so pointers to any of
them actually work interchangeably. I have seen platforms, but only a
handful, where varargs are different, and mixing pointers to them (or
misdeclaring) does cause (serious) problems.

> other pointers can have their own representation.  All pointers
> can be converted to and from pointers to void, without loss.  And

All _data_ pointers can be converted to and from void* without loss.
All function pointers can  be converted to other function pointers
without loss; at least formally you must convert back before using.

> pointers can have different sizes and different patterns for the
> null pointer.  I suspect a lot of code would fail if compilers
> wanted to exercise their full freedoms!

Agree with both of those.

- David.Thompson1 at worldnet.att.net



  parent reply	other threads:[~2006-03-27  4:07 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-13 19:58 private types ada_student
2006-03-13 20:27 ` Mark Lorenzen
2006-03-13 21:05   ` Pascal Obry
2006-03-13 21:07   ` ada_student
2006-03-13 21:45     ` Simon Wright
2006-03-14  4:51 ` Jeffrey R. Carter
2006-03-14  7:44   ` Brian May
2006-03-14  8:25     ` Ludovic Brenta
2006-03-14  8:47     ` Alex R. Mosteo
2006-03-17  4:33     ` Justin Gombos
2006-03-17  5:17       ` Brian May
2006-03-17 22:50         ` Justin Gombos
2006-03-18  1:17         ` Randy Brukardt
2006-03-18  2:17           ` Justin Gombos
2006-03-21  0:08             ` Randy Brukardt
2006-03-18  8:39           ` Uninitialized variables (was: Re: private types) Dirk Craeynest
2006-03-18 14:06             ` Gautier
2006-03-18 14:36               ` Uninitialized variables Jeffrey Creem
2006-03-21  0:22             ` Uninitialized variables (was: Re: private types) Randy Brukardt
2006-03-21  0:38             ` Randy Brukardt
2006-03-18 12:06           ` private types Martin Dowie
2006-03-18 12:47           ` Robert A Duff
2006-03-17  7:40       ` Maciej Sobczak
2006-03-17 16:41         ` Frank J. Lhota
2006-03-17 23:36         ` Justin Gombos
2006-03-18  1:32           ` Randy Brukardt
2006-03-18  3:21             ` Handling invalid objects Justin Gombos
2006-03-18  7:35               ` Jeffrey R. Carter
2006-03-18 16:10                 ` Justin Gombos
2006-03-19 11:00                   ` Simon Wright
2006-03-20 23:57                   ` Randy Brukardt
2006-03-22  2:06                     ` Justin Gombos
2006-03-22  5:23                       ` tmoran
2006-03-22  8:48                         ` Dmitry A. Kazakov
2006-03-22  9:24                           ` Maciej Sobczak
2006-03-22 11:05                             ` Dmitry A. Kazakov
2006-03-22 16:42                               ` Maciej Sobczak
2006-03-22 18:06                                 ` Stefan Lucks
2006-03-23 13:20                                 ` Dmitry A. Kazakov
2006-03-18  8:57               ` Jacob Sparre Andersen
2006-03-19 19:07                 ` Dr. Adrian Wrigley
2006-03-20 15:25                   ` Robert A Duff
2006-03-19 22:06               ` Brian May
2006-03-20 21:17                 ` Jeffrey R. Carter
2006-03-20 23:44               ` Randy Brukardt
2006-03-22  1:27                 ` Justin Gombos
2006-03-18  9:20           ` private types Dmitry A. Kazakov
2006-03-17 13:18       ` Robert A Duff
2006-03-17 23:44         ` Justin Gombos
2006-03-18  9:24           ` Dmitry A. Kazakov
2006-03-18 12:56           ` Robert A Duff
2006-03-18 15:06             ` Justin Gombos
2006-03-19  9:35               ` Martin Krischik
2006-03-19 14:52                 ` Peter C. Chapin
2006-03-19 15:08                   ` Björn Persson
2006-03-19 16:34                     ` Martin Krischik
2006-03-20  9:57                       ` Maciej Sobczak
2006-03-20 10:58                         ` Peter C. Chapin
2006-03-20 11:19                           ` Peter C. Chapin
2006-03-20 13:06                           ` Maciej Sobczak
2006-03-20 15:19                         ` Robert A Duff
2006-03-20 16:47                           ` James Dennett
2006-03-20 19:12                         ` Martin Krischik
2006-03-21  7:27                           ` Maciej Sobczak
2006-03-20 19:32                         ` Martin Krischik
2006-03-21  7:41                           ` Maciej Sobczak
2006-03-20 20:29                       ` Simon Wright
2006-03-19 17:43                     ` Larry Kilgallen
2006-03-19 22:11                     ` Peter C. Chapin
2006-03-19 18:15                 ` Robert A Duff
2006-03-19 19:20                   ` Martin Krischik
2006-03-19 20:43                     ` Dr. Adrian Wrigley
2006-03-20 15:01                       ` Robert A Duff
2006-03-27  4:07                       ` Dave Thompson [this message]
2006-03-20  9:40                     ` Maciej Sobczak
2006-03-20 15:09                       ` Robert A Duff
2006-03-21  8:07                         ` Maciej Sobczak
2006-03-26 18:53                           ` Robert A Duff
2006-03-19 19:27                 ` Jeffrey R. Carter
2006-03-25 21:40               ` Robert A Duff
2006-03-26  0:10                 ` Justin Gombos
2006-03-26  1:00                   ` Robert A Duff
2006-03-26  6:37                     ` Jeffrey R. Carter
2006-03-26 15:43                       ` Justin Gombos
2006-03-26 16:32                         ` Robert A Duff
2006-03-26 16:51                       ` Robert A Duff
2006-03-26 19:41                         ` Jeffrey R. Carter
2006-03-26  3:15                 ` Frank J. Lhota
2006-03-26 18:28                   ` Robert A Duff
2006-03-26 19:43                     ` Jeffrey R. Carter
2006-03-26 19:59                     ` Simon Wright
     [not found] <bctruong.1.00117123@draper.com>
1999-07-28  0:00 ` Stanley R. Allen
1999-07-28  0:00   ` Thomas Hood
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox