c - 空函数的大小
问题描述
我在 c 中遇到过 void 函数。而且我知道这些函数不会返回任何值,但会有一个返回语句。我试图用 sizeof 运算符查看函数的大小。打印的值为 1 作为 void 函数的大小。谁能解释一下 1 是函数的大小?
下面是我用过的程序。
#include <stdio.h>
void my_func()
{
printf("From void my_function\n");
return ;
}
int func()
{
printf("From int func\n");
return 0;
}
int main()
{
printf("Size of void function : %lu\n",sizeof(my_func())); // 1 is printed
printf("Size of integer function : %lu\n",sizeof(func())); // 4 is printed
return 0;
}
解决方案
推荐阅读
- events - Infragistics UltraGrid 组更改事件
- user-accounts - 有人支持 RISC 或 SecEvents 规范吗?
- spring-mvc - 如果表单动作属性中没有定义@RequestMapping("/someAction"),Spring mvc如何知道该怎么做
- android - 无法在设备上加载 APK,因为不存在的模拟器在 Android Studio 3.3 中出现和消失
- kubernetes - Kubernetes OpenID Connect 身份验证失败时的日志
- php - 日期不通过 echo 输出
- spring - 应用安全过滤器后,Zuul 路由不会重定向到给定的 URL
- angular - RXJS 6:使用异步过滤器对数组进行递归过滤
- azure - 尝试将战争部署到 Azure 时出现问题
- jsrender - JsRender - 在助手中调用助手