Re: C programming question

From: Mike Meyer (mwm_at_mired.org)
Date: 04/04/05

  • Next message: gilles chehade: "Re: C programming question"
    Date: Mon, 4 Apr 2005 13:47:27 -0500
    To: Matt <mhersant@comcast.net>
    
    

    In <42518AC9.5070208@comcast.net>, Matt <mhersant@comcast.net> typed:
    > 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.

    cdecl (in the ports tree) is your friend:

    guru% cdecl
    Type `help' or `?' for help
    explain int (*if_ioctl)(struct ifnet *, int, caddr_t);
    declare if_ioctl as pointer to function (pointer to struct ifnet, int, caddr_t) returning int
    explain int (*if_watchdog)(int);
    declare if_watchdog as pointer to function (int) returning int

    Note that the parens around the "pointer to function" part are required:

    explain int *if_watchdog(int);
    declare if_watchdog as function (int) returning pointer to int

            <mike

    -- 
    Mike Meyer <mwm@mired.org>		http://www.mired.org/consulting.html
    Independent Network/Unix/Perforce consultant, email for more information.
    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
    

  • Next message: gilles chehade: "Re: C programming question"

    Relevant Pages