🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac.programmer.codewarrior
Article #822

Re: Function pointer casting

#822
From: David Phillip Oster
Date: Mon, 02 Jun 2003 16:24
28 lines
2907 bytes
In article <3EDB6B20.2000804@lgl.kos.net>,
 Edward Chew <ekc-noreply@lgl.kos.net> wrote:

>      if(static_cast<void*>(LibraryInitFunction) ==
>         static_cast<void*>(kUnresolvedCFragSymbolAddress)
>         )
>           reportLibraryUnavailable();
> 
> This seems to work fine, but now I am told it is illegal as well.  What 
> would be the proper test in that case?

#define kUnresolvedCFragSymbolAddress \
      static_cast<int>(kUnresolvedCFragSymbolAddress)

      if(LibraryInitFunction == kUnresolvedCFragSymbolAddress){
      }

Discussion: It is always legal to compare a pointer of any type to zero.
(int Zero is special this way. (Long zero ( 0L ) is not.))
In this context, a bare zero would be misleading. We give zero a 
symbolic name, like NULL and noErr are symbolic names for zero, and you
use the correct one, depending on a context, as an aid to those who
will read your source code in the future.

Apple mistakenly defined kUnresolvedCFragSymbolAddress as 0 in an enum,
rather than a #define, which is OK for C but not for C++. The #define
definition overrides the enum definition. A bug report with Apple should
be filed on this.
Technical Details
Message-ID: <oster-60D1EB.09243502062003@newssvr21-ext.news.prodigy.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!pd2nf1so.cg.shawcable.net!residential.shaw.ca!prodigy.com!newsmst01.news.prodigy.com!prodigy.com!postmaster.news.prodigy.com!newssvr21.news.prodigy.com.POSTED!05585bd2!not-for-mail
References: <3ED6734A.6080600@lgl.kos.net> <mwron-5286CB.09413702062003@enews.newsguy.com> <3EDB6B20.2000804@lgl.kos.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10bcce,9c35d45628066e65
X-Google-Attributes: gid10bcce,public
X-Google-Thread: f635e,9c35d45628066e65
X-Google-Attributes: gidf635e,public
X-Google-ArrivalTime: 2003-06-02 09:25:03 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!pd2nf1so.cg.shawcable.net!residential.shaw.ca!prodigy.com!newsmst01.news.prodigy.com!prodigy.com!postmaster.news.prodigy.com!newssvr21.news.prodigy.com.POSTED!05585bd2!not-for-mail
From: David Phillip Oster <oster@ieee.org>
Newsgroups: comp.sys.mac.programmer.codewarrior,codewarrior.mac
Subject: Re: Function pointer casting
Organization: http://www.TurboZen.com
References: <3ED6734A.6080600@lgl.kos.net> <mwron-5286CB.09413702062003@enews.newsguy.com> <3EDB6B20.2000804@lgl.kos.net>
User-Agent: MT-NewsWatcher/3.2 (PPC Mac OS X)
X-Face: iR>C6?LNAcg&!xxr{}\7y$W@~UW,\:5'<H=KmFr^OY!`48#Nqao]VO#+oxocr        ="e"*!AxDM1my!y7uoK4<&hQ-9c\KxG_b3eD{JlM2+r0BYXAo<~N|g'3p<tXe37b[79@        ?46JFrQ?^D479N=<Au~;,ax]LOils0QyP.qY!Mw5o'2$<qA{V)<J-<2Y8K
Message-ID: <oster-60D1EB.09243502062003@newssvr21-ext.news.prodigy.com>
Lines: 28
NNTP-Posting-Host: 64.167.142.226
X-Complaints-To: abuse@prodigy.net
X-Trace: newssvr21.news.prodigy.com 1054571095 ST000 64.167.142.226 (Mon, 02 Jun 2003 12:24:55 EDT)
NNTP-Posting-Date: Mon, 02 Jun 2003 12:24:55 EDT
X-UserInfo1: Q[R_PJSCOXUUC\\Y\RJF_PTDEB\@PD\MNPWZKB]MPXHZUYICD^RAQBKZQTZTX\_I[^G_KGFNON[ZOE_AZNVO^\XGGNTCIRPIJH[@RQKBXLRZ@CD^HKANYVW@RLGEZEJN@\_WZJBNZYYKVIOR]T]MNMG_Z[YVWSCH_Q[GPC_A@CARQVXDSDA^M]@DRVUM@RBM
Date: Mon, 02 Jun 2003 16:24:55 GMT