user3653348
user3653348

Reputation: 45

Pointer In Function Name / Pointer Function

I'm learning C, I was looking at https://github.com/mruby/mruby/blob/master/src/load.c and this line made me very confused:

mrb_irep* read_irep_record_1

On line 40.

I can see that this is a pointer of some sort. What I'd like to know is the following What does this do? How do you use them? What are these called? How do they work? How can I replicate this in a program? I've only this used in C projects, is it recommended to use these in C++? Can you do this in C++?

I searched a bit on Stackoverflow for pointer functions but couldn't find anything like this.

Thanks in advance!

Upvotes: 0

Views: 90

Answers (1)

wolfPack88
wolfPack88

Reputation: 4203

That line is simply declaring a function that returns a pointer to mrb_irep. For example, what does a function declared as int foo() return? Well it returns an int, as we see in the declaration. Similarly, a function declared as mrb_irep* read_irep_record_1(...) returns a variable of type mreb_irep*, or a pointer to a struct called mreb_irep.

Upvotes: 2

Related Questions