0

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!

4
  • Are you referring to line 40 of that code? Commented Jun 11, 2014 at 18:13
  • It's just a pointer to a regular struct called mrb_irep. Your questions are rather basic, and they require long answers. I suggest reading a book or googling for C or C++ introduction. Commented Jun 11, 2014 at 18:17
  • I'm reading C Primer Plus. Commented Jun 11, 2014 at 18:19
  • Then read page 657. Commented Jun 11, 2014 at 18:21

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.