From owner-freebsd-standards@FreeBSD.ORG Wed Apr 20 16:23:53 2005 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0E85716A4CE for ; Wed, 20 Apr 2005 16:23:53 +0000 (GMT) Received: from kane.otenet.gr (kane.otenet.gr [195.170.0.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id CB69F43D4C for ; Wed, 20 Apr 2005 16:23:45 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from orion.daedalusnetworks.priv (aris.bedc.ondsl.gr [62.103.39.226])j3KGMSXg008885; Wed, 20 Apr 2005 19:22:32 +0300 Received: from orion.daedalusnetworks.priv (orion [127.0.0.1]) j3KGNX7f053034; Wed, 20 Apr 2005 19:23:33 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost)j3KGNW1t053033; Wed, 20 Apr 2005 19:23:32 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Wed, 20 Apr 2005 19:23:32 +0300 From: Giorgos Keramidas To: Joseph Koshy Message-ID: <20050420162332.GB52948@orion.daedalusnetworks.priv> References: <84dead720504200541539f4c15@mail.gmail.com> <03f22a3c76ac440b97e2179761dfd6fa@xcllnt.net> <20050420155407.GA844@falcon.midgard.homeip.net> <84dead720504200910441b9108@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <84dead720504200910441b9108@mail.gmail.com> cc: freebsd-standards@freebsd.org Subject: Re: Standard type for code pointers? X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2005 16:23:53 -0000 On 2005-04-20 16:10, Joseph Koshy wrote: >> Except that intptr_t need only be large enough to hold an object >> pointer. This is not necessarily enough to hold a function pointer. > > Right. > >> The only standard types that are guaranteed to be able to hold a >> function pointer are other function pointers. > > Right, but there doesn't seem to be a C99 name for function > pointer types. There is no need for an explicit typedef. If you do know the type of the function pointed at by a function pointer, you can declare the pointer using the correct type: char prog_name[] = "/bin/sh"; char *args[] = { prog_name }; int (*fptr)(int, char **); fptr = main; fptr(1, args); > Is 'register_t' guaranteed to be wide enough? AFAIK, no. Portable C code cannot assume that a function pointer is small enough to fit in a single machine register. Some obscure architecture may choose to represent function entry points with as many register as it needs.