简体   繁体   English

功能名称中的指针/指针功能

[英]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: 我正在学习C,我在看https://github.com/mruby/mruby/blob/master/src/load.c ,这行让我非常困惑:

mrb_irep* read_irep_record_1

On line 40. 在第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++? 我只在C项目中使用过它,建议在C ++中使用它们吗? Can you do this in C++? 可以用C ++做到吗?

I searched a bit on Stackoverflow for pointer functions but couldn't find anything like this. 我在Stackoverflow上搜索了一些指针函数,但找不到类似的东西。

Thanks in advance! 提前致谢!

That line is simply declaring a function that returns a pointer to mrb_irep . 该行只是在声明一个函数,该函数返回指向mrb_irep的指针。 For example, what does a function declared as int foo() return? 例如,声明为int foo()的函数返回什么? Well it returns an int , as we see in the declaration. 好吧,它返回一个int ,正如我们在声明中看到的那样。 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 . 同样,声明为mrb_irep* read_irep_record_1(...)的函数返回类型为mreb_irep*的变量,或指向名为mreb_irep的结构的指针。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM