Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > A slightly more complicated function pointer declaration

Reply
Thread Tools

A slightly more complicated function pointer declaration

 
 
Tobias Oed
Guest
Posts: n/a
 
      07-10-2003
Jason wrote:

> char * const * (*fn)(void);
>
> Seems rarther confusing to me, becuase of the way const can be used, like
> this:
>
> const char * a; /* pointer to const char */
> char const * a; /* pointer to const char */
> char * const a; /* const pointer to char */
>
> I would guess that function declaration means this:
>
> A pointer to a function returning a pointer to a const pointer to a char.
> Is there a good way of reading things such as this?


When I am tired I use cdecl:

qcd:~$ cdecl
Type `help' or `?' for help
cdecl> explain char * const * (*fn)(void);
declare fn as pointer to function (void) returning pointer to const pointer
to char
cdecl>

Tobias.

--
unix http://www.faqs.org/faqs/by-newsgrou...rogrammer.html
clc http://www.eskimo.com/~scs/C-faq/top.html
fclc (french): http://www.isty-info.uvsq.fr/~rumeau/fclc/
 
Reply With Quote
 
 
 
 
Jason
Guest
Posts: n/a
 
      07-10-2003
char * const * (*fn)(void);

Seems rarther confusing to me, becuase of the way const can be used, like
this:

const char * a; /* pointer to const char */
char const * a; /* pointer to const char */
char * const a; /* const pointer to char */

I would guess that function declaration means this:

A pointer to a function returning a pointer to a const pointer to a char. Is
there a good way of reading things such as this?


 
Reply With Quote
 
 
 
 
Jason
Guest
Posts: n/a
 
      07-12-2003

"Jason" <@> wrote in message news:3f0ddabc@shknews01...
> char * const * (*fn)(void);
>
> Seems rarther confusing to me, becuase of the way const can be used, like
> this:
>
> const char * a; /* pointer to const char */
> char const * a; /* pointer to const char */
> char * const a; /* const pointer to char */
>
> I would guess that function declaration means this:
>
> A pointer to a function returning a pointer to a const pointer to a char.

Is
> there a good way of reading things such as this?
>
>


Any hints?


 
Reply With Quote
 
Jason
Guest
Posts: n/a
 
      07-12-2003

"Jason" <@> wrote in message news:3f0fd299@shknews01...
....
> Any hints?

....

Sorry, newsfeed very slow.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
type declaration in declaration of a parameter or return type of a function Luca Forlizzi C Programming 4 11-14-2010 09:30 PM
complicated declaration asit C Programming 3 03-13-2008 06:10 PM
Can a static function declaration conflict with a non-static declaration? nospam_timur@tabi.org C Programming 4 12-12-2006 10:26 PM
Variable declaration taken as a function pointer declaration Bolin C++ 4 12-02-2005 05:28 PM
Function declaration in class declaration Ovidesvideo C++ 4 12-10-2004 06:36 PM



Advertisments