简体   繁体   English

这是什么类型的函数(带代码的指针函数)?

[英]What type of function is this (pointer function with code)?

This is the first time I am seeing something like this where a function is like a pointer (but it is not a function pointer ??).这是我第一次看到这样的东西,其中一个函数就像一个指针(但它不是一个函数指针??)。 See example below.请参阅下面的示例。

static struct test *MyFunc(struct astr *A, int count)
{

}

MyFunc(B, 100);

Can someone explain how the above works as well as why you would use a pointer function (if that is the correct term) as well as why not simply use有人可以解释上面的工作原理以及为什么要使用指针函数(如果这是正确的术语)以及为什么不简单地使用

 static struct test MyFunc(struct astr *A, int count)

可以这样想:

static (struct test *) MyFunc(struct astr *A, int count)

So let's look at the function declaration:那么让我们看看函数声明:

static struct test *MyFunc(struct astr *A, int count)

The function itself is static (Local to the file it was declared in), and returns a pointer (Location in memory) to a value with a struct test type.该函数本身是静态的(在声明它的文件的本地),并返回一个指针(内存中的位置)指向具有struct test类型的值。 In other words, it is a static function with return type struct test * .换句话说,它是一个返回类型为struct test *静态函数。

Remember: Static function declarations specify the storage class of the function itself , not the return type .记住:静态函数声明指定了函数本身的存储类,而不是返回类型

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

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