<sent to mod without subject> 
Author Message
 <sent to mod without subject>

Quote:

> I have no clue what you mean about pointer to pointer to void not being
> portable - I use it occasionally.

Right out of the C FAQ:

2.19:   Can I use a void ** pointer to pass a generic pointer to
        a function by reference?                                            

A:      Not portably.  There is no generic pointer-to-pointer type in
        C. void * acts as a generic pointer only because conversions
        applied automatically when other pointer types are assigned to  
        and from void *'s; these conversions cannot be performed (the  
        correct underlying pointer type is not known) if an attempt is  
        made to indirect upon a void ** value which points at something
        other than a void *.                                            

That is what is holding me up; otherwise I would have happily done a void
** already. :-)

Quote:
> Casting function pointers is not officially portable.

Okay. Thats what everyone says. I guess my copy of the ANSI C standard is
wrong, because in 3.2.2.3 (Automatic Conversion of Pointers):

     A pointer to void may be converted to or from a pointer to any
  incomplete or object type.  A pointer to any incomplete or object type
  may be converted to a pointer to void and back again; the result shall
  compare equal to the original pointer.              

I thought that "any incomplete or object type" referred to functions as
well. So, I guess it doesn't. Sigh. A "generic function pointer" would be
real handy for a piece of code I am writing. Sigh.

L8r,
Mark G.



Fri, 12 Jun 1998 03:00:00 GMT  
 <sent to mod without subject>


 >
 > > I have no clue what you mean about pointer to pointer to void not being
 > > portable - I use it occasionally.
 >
 > Right out of the C FAQ:
 >
 > 2.19:   Can I use a void ** pointer to pass a generic pointer to
 >         a function by reference?                                            
 >                                                                            
 > A:      Not portably.  There is no generic pointer-to-pointer type in
 >         C. void * acts as a generic pointer only because conversions
 >         applied automatically when other pointer types are assigned to  
 >         and from void *'s; these conversions cannot be performed (the  
 >         correct underlying pointer type is not known) if an attempt is  
 >         made to indirect upon a void ** value which points at something
 >         other than a void *.                                            
 >
 > That is what is holding me up; otherwise I would have happily done a void
 > ** already. :-)

The last sentence makes it clear that void ** can point to a void *. It
just can't point portably to anything else.

...
 > Okay. Thats what everyone says. I guess my copy of the ANSI C standard is
 > wrong, because in 3.2.2.3 (Automatic Conversion of Pointers):
...

 > I thought that "any incomplete or object type" referred to functions as
 > well. So, I guess it doesn't.

Indeed it does not. The first paragraph of ANSI Classic 3.1.2.5 should make
this clear.

 > Sigh. A "generic function pointer" would be
 > real handy for a piece of code I am writing. Sigh.

Read ANSI Classic 3.3.4. The last paragraph explains that any function
pointer may be converted to a pointer to a function of any other type and
back again (however this can't be done implicitly - a cast is required).
This should be all you need. If not you should explain the problem a little
more.

--
-----------------------------------------


-----------------------------------------



Sun, 14 Jun 1998 03:00:00 GMT  
 <sent to mod without subject>
:  > Right out of the C FAQ:

[Snipped because of bandwith]

:  >         made to indirect upon a void ** value which points at something
:  >         other than a void *.                                            
:  >
:  > ** already. :-)

: The last sentence makes it clear that void ** can point to a void *. It
: just can't point portably to anything else.

Ahh.. That makes much more sense, since I will just be pointing into my
own array of void *'s. Thanks a million! (*BONK*)

: Indeed it does not. The first paragraph of ANSI Classic 3.1.2.5 should make
: this clear.

:  > Sigh. A "generic function pointer" would be
:  > real handy for a piece of code I am writing. Sigh.

: Read ANSI Classic 3.3.4. The last paragraph explains that any function
: pointer may be converted to a pointer to a function of any other type and
: back again (however this can't be done implicitly - a cast is required).
: This should be all you need. If not you should explain the problem a little
: more.

Thanks again!

L8r,
Mark G.
  - Strange, I had a subject on this when I sent it out!
    I wonder if sendmail is broke here; I would use one of my accounts
    at school except their news server is unreliable to read clcm.



Tue, 16 Jun 1998 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Do my homework, I'm lazy [submitted without subject -mod]

2. <<<<<<<Parsing help, please>>>>>>>>

3. File Format conversion, ascii freeform -->.csv <-->.wk1<-->dbf<-->?HELP

4. <<<>>>Need C code advice with functions and sorting.<<<>>>

5. <><><>HELP<><><> PCMCIA Motorola Montana 33.6

6. >>>Windows Service<<<

7. <no subject>

8. <no subject>

9. <no subject>

10. <no subject>

11. <no subject>

12. <no subject>

 

 
Powered by phpBB® Forum Software