🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2517

Re: Pointers to functions

#2517
From: Richard A. O'Keefe
Date: Fri, 05 Apr 1996 00:50
31 lines
1527 bytes
Lloyd Hopkins <Lloyd@bomber.demon.co.uk> writes:
>I am having some difficulty with some of the examples in 5.12.  The first
>few are straight forward enough, but (for example):

>char (*(*x[3])())[5]

>is pretty confusing to figure!

There is a free program available on the net called "cdecl".

g% cdecl
Type `help' or `?' for help
cdecl> explain char (*(*x[3])())[5]
declare x as array 3 of pointer to
  function returning pointer to array 5 of char
cdecl> quit

It's very useful for reading other people's code.
Weird declarations like that are seldom useful.
More usual would be

    typedef char (*five_char_ptr)[5];
    typedef five_char_ptr (*five_char_function_ptr)();
    five_char_function_ptr x[3];

I can live with two type constructors (*, [], or ()) in a declaration,
but three is a bit too much.

-- 
Result of state election = 50% Victorians didn't get MP of their choice.
Richard A. O'Keefe; http://www.cs.rmit.edu.au/~ok; RMIT Comp.Sci.
Technical Details
Message-ID: <4k1qp8$5nn@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4jol6u$1sn@solutions.solon.com> <4jq1ef$a2u@solutions.solon.com> <4jttba$3gt@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: ok@cs.rmit.edu.au (Richard A. O'Keefe)
Newsgroups: comp.lang.c.moderated
Subject: Re: Pointers to functions
Date: 4 Apr 1996 18:50:48 -0600
Organization: Comp Sci, RMIT, Melbourne, Australia
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4k1qp8$5nn@solutions.solon.com>
References: <4jol6u$1sn@solutions.solon.com> <4jq1ef$a2u@solutions.solon.com> <4jttba$3gt@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com
X-Newsreader: NN version 6.5.0 #0 (NOV)