From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ec21c3c7cdc7ff3e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news4.google.com!news.glorb.com!wn14feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail From: Dave Thompson Newsgroups: comp.lang.ada Subject: Re: private types Message-ID: <8cb922hgoa60qejbtm7a44uejgdtrlpajm@4ax.com> References: <1259548.CMTukHGvVZ@linux1.krischik.com> <9006286.GT9LdmDZaR@linux1.krischik.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 27 Mar 2006 04:07:46 GMT NNTP-Posting-Host: 12.76.19.112 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1143432466 12.76.19.112 (Mon, 27 Mar 2006 04:07:46 GMT) NNTP-Posting-Date: Mon, 27 Mar 2006 04:07:46 GMT Organization: AT&T Worldnet Xref: g2news1.google.com comp.lang.ada:3645 Date: 2006-03-27T04:07:46+00:00 List-Id: -- On Sun, 19 Mar 2006 20:43:42 GMT, "Dr. Adrian Wrigley" 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