Re: Cannot understand the following codes



On 2006-03-29, Joe Wright <joewwright@xxxxxxxxxxx> wrote:
Ben C wrote:
[..]
I had assumed void * was good for anything. But it's only good for data,
not functions.

I suppose on some machines functions might have a completely different
address space, be a completely different size etc., and the standard is
allowing for that...

Pedantically void pointers and function pointers are not compatible.
But is a less pedantic world it might work.. if you change your line

int x = (*r)(3);

to

int x = (r)(3); or even

int x = r(3);

Isn't this a different issue? I don't know what the standard says about
r(3), although it usually works.
.



Relevant Pages

  • Re: Compiler Error
    ... is preferred to "void main" ... I'd have used a stronger expression than that. ... actually requires int in almost all situations in which the Standard ...
    (comp.lang.c)
  • Re: Question about pointers?
    ... > with the exception of the void fileexistcheckthat is OS ... I hope the rest of it is totally standard. ... > int main ... > void selectfilename(string& filename) ...
    (comp.lang.cpp)
  • Re: Memory allocation for an initialized character pointer;
    ... where does the Standard explicitly mention void ... the Standard does not imply by that text that void mainis ... any more than the Standard implies by the same text that struct ... Neither does it imply that int mainis correct, because, as you ...
    (comp.lang.c)
  • Re: Legality of void main in C
    ... § 5.1.2.2.1.1 of the C ... Standard lists the allowable forms for the definition of main. ... If the return type is not compatible with int, ... an implementation is permitted to allow void main. ...
    (comp.lang.c)
  • Re: Global variable conflict.
    ... > void tf; ... > int main ... under the C standard your program has undefined behavior. ... have two definitions for the same int with external linkage. ...
    (comp.unix.programmer)