Re: Pointer Indirection Syntax
From: Eric Amick (eric-amick_at_comcast.net)
Date: 04/08/04
- Next message: code_wrong: "Re: how to remove a character from a string"
- Previous message: Martin Dickopp: "Re: main function address"
- In reply to: Joona I Palaste: "Re: Pointer Indirection Syntax"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 07 Apr 2004 19:04:30 -0400
On 7 Apr 2004 19:00:51 GMT, Joona I Palaste <palaste@cc.helsinki.fi>
wrote:
>Thomas Matthews <Thomas_MatthewsSpitsOnSpamBots@sbcglobal.net> scribbled the following:
>> Hi,
>
>> At my work, we have a need for a pointer to a pointer
>> to a function returning void and having void parameters.
>
>> Since this is an embedded system, we have to assign the
>> variable with a constant value (address).
>
>> We came up with the following:
>> #define LOCATION 0x10000
>> typedef void (*FuncPtr)(void);
>> typedef *FuncPtr PtrFuncPtr;
>> What is the syntax for declaring a pointer to a pointer
>> to a function taking no parameters and returning void?
>> {In other words, what is the syntax to combine the
>> two typedefs into one?}
>> {Or /where does the 2nd asterisk (*) get placed?}
>
>Let me try this by hand. I might screw up, so any C gurus out there,
>feel free to correct me.
>Function taking no parameters and returning void:
>void function(void)
>Pointer to a function taking no parameters and returning void:
>void (*function)(void)
>Pointer to a pointer to a function taking no parameters and returning
>void:
>void (**function)(void)
>I believe that's it.
That's fine, and the original typedefs were *almost* correct. Note the
change in the second:
typedef void (*FuncPtr)(void);
typedef FuncPtr *PtrFuncPtr;
In general, to create a typedef, declare a variable of the appropriate
type, then stick "typedef" in front.
-- Eric Amick Columbia, MD
- Next message: code_wrong: "Re: how to remove a character from a string"
- Previous message: Martin Dickopp: "Re: main function address"
- In reply to: Joona I Palaste: "Re: Pointer Indirection Syntax"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|