void*

  • Thread starter Guybrush Threepwood
  • Start date
G

Guybrush Threepwood

a function declared as

void* someFunction()
{
....
}

what does it exactly return?
 
K

Karl Heinz Buchegger

Guybrush said:
a function declared as

void* someFunction()
{
...
}

what does it exactly return?

a pointer to void.
That is a pointer to ... aehm ... something, but nobody
knows to what exactly.
 
R

Rolf Magnus

Karl said:
a pointer to void.
That is a pointer to ... aehm ... something, but nobody
knows to what exactly.

I hope that there is at least somebody out there who knows what it is.
If not, why return a pointer to it? ;-)
 
E

E. Robert Tisdale

Guybrush said:
a function declared as

void* someFunction()
{
...
}

That's *not* a declaration.
It's a definition.
The declaration

void* someFunction(void);

informs the compiler that someFunction returns a pointer to memory.
what does it exactly return?

This depends upon the definition

void* someFunction(void) {
return malloc(sizeof(int));
}

for example.
 
M

Mike Wahler

E. Robert Tisdale said:
That's *not* a declaration.

Oh, yes it certainly is (barring the syntax error)
See 3.1 / 2 and 7 / 1.
It's a definition.

Yes, it's that as well.
The declaration

void* someFunction(void);

informs the compiler that someFunction returns a pointer to memory.

So does the declaration posted by the OP.


-Mike
 
M

Mike Wahler

Makhno said:
What syntax error?

The line with the three periods.
If you want to use such to indicate e.g.
"other stuff goes here", put it in a comment.

I know this case isn't really a good example, but
you'll find that more help is available if posted
code can be copy-pasted and compiled verbatim.

-Mike
 
G

Guybrush Threepwood

Mike said:
The line with the three periods.
If you want to use such to indicate e.g.
"other stuff goes here", put it in a comment.

I know this case isn't really a good example, but
you'll find that more help is available if posted
code can be copy-pasted and compiled verbatim.

-Mike
<sigh>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,163
Messages
2,570,897
Members
47,434
Latest member
TobiasLoan

Latest Threads

Top