当前位置:网站首页>Sizeof (function name) =?
Sizeof (function name) =?
2022-07-05 08:05:00 【Car chezi】
sizeof( Function name )=?
Go straight to the code
#include <stdio.h>
int foo(void)
{
printf("hello\n");
return 0;
}
int main(void)
{
printf("%lu\n", sizeof(foo));
printf("%lu\n", sizeof(&foo));
printf("%lu\n", sizeof(foo()));
}
Suppose saved as a file 1.c
compile :
$ gcc -Wall -pedantic 1.c -std=c99
warning: invalid application of ‘sizeof’ to a function type [-Wpointer-arith]
printf("%lu\n", sizeof(foo));
The result of the operation is :
1
8
4
explain :
-pedantic Options : Show all ISO C and ISO C++ Warning .
about sizeof(foo), I think it should be that function indicators are automatically converted into pointers , The answer should be 8, But not so , Compiler derived 1. It seems that the standard does not allow function indicators to be used as sizeof The number of operations , Or it doesn't make sense .
sizeof(&foo): Function designators are explicitly converted to pointers to functions , So the answer is 8
sizeof(foo()):sizeof The operand of is the return type of the function , So it is 4
【End】
边栏推荐
- L'étude a révélé que le système de service à la clientèle du commerce électronique transfrontalier a ces cinq fonctions!
- The printer encountered an abnormal configuration problem 0x8007007e (win10)
- Introduction of air gap, etc
- UEFI development learning 3 - create UEFI program
- Basic information commands and functions of kernel development
- 1089 Insert or Merge 含测试点5
- Shape template matching based on Halcon learning [v] find_ cocoa_ packages_ max_ deformation. Hdev routine
- Halcon's practice based on shape template matching [2]
- Count and sort the occurrence times of specific fields through SQL statements
- The global and Chinese market of lithographic labels 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
Can't find real-time chat software? Recommend to you what e-commerce enterprises are using!
L'étude a révélé que le système de service à la clientèle du commerce électronique transfrontalier a ces cinq fonctions!
Semiconductor devices (III) FET
[tutorial 19 of trio basic from introduction to proficiency] detailed introduction of trio as a slave station connecting to the third-party bus (anybus PROFIBUS DP...)
Ads learning record (lna_atf54143)
Embedded composition and route
如何进行导电滑环选型
[trio basic tutorial 18 from introduction to proficiency] trio motion controller UDP fast exchange data communication
如何将EasyCVR平台RTSP接入的设备数据迁移到EasyNVR中?
C WinForm [view status bar -- statusstrip] - Practice 2
随机推荐
Mlperf training v2.0 list released, with the same GPU configuration, the performance of Baidu PaddlePaddle ranks first in the world
Global and Chinese markets for flexible endoscopic lithotripsy devices 2022-2028: Research Report on technology, participants, trends, market size and share
Introduction of air gap, etc
Process communication mode between different hosts -- socket
[trio basic tutorial 17 from getting started to mastering] set up and connect the trio motion controller and input the activation code
Global and Chinese market for blood typing 2022-2028: Research Report on technology, participants, trends, market size and share
导电滑环磨损快的原因
Screen record of the opening ceremony of the Beijing winter olympics 2
[trio basic from introduction to mastery tutorial 20] trio calculates the arc center and radius through three points of spatial arc
Consul安装
How to migrate the device data accessed by the RTSP of the easycvr platform to easynvr?
UEFI development learning 4 - getting to know variable services
Development tools -- gcc compiler usage
C WinForm [exit application] - practice 3
String judgment
Shell脚本基本语法
Global and Chinese markets for anesthesia, breathing and sleep apnea devices 2022-2028: Research Report on technology, participants, trends, market size and share
UEFI development learning 2 - running ovmf in QEMU
matlab timeserise
The browser cannot access Baidu