Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Apr 2005 13:55:38 -0500
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Matt <mhersant@comcast.net>
Cc:        misc@openbsd.org
Subject:   Re: C programming question
Message-ID:  <20050404185538.GB42193@dan.emsphone.com>
In-Reply-To: <42518AC9.5070208@comcast.net>
References:  <42518AC9.5070208@comcast.net>

next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Apr 04), Matt said:
> I need some help understanding some C code. 
> 
> int     (*if_ioctl)
>        (struct ifnet *, int, caddr_t);
> 
> int     (*if_watchdog)
>        (int);
> 
> Can someone break down these declarations (if that's what they are)?  Is 
> this a form of typecasting?  Thanks for your help.

The cdecl command (ports/devel/cutils) is good as decoding stuff like
this.  Those two lines declare variables that are pointers to
functions.

$ cdecl explain "int (*if_ioctl) (struct ifnet *, int, caddr_t)"
declare if_ioctl as pointer to function (pointer to struct ifnet, int, addr_t) returning int
$ cdecl explain "int (*if_watchdog) (int)"
declare if_watchdog as pointer to function (int) returning int

-- 
	Dan Nelson
	dnelson@allantgroup.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050404185538.GB42193>