当前位置:网站首页>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】
边栏推荐
- LED display equipment records of the opening ceremony of the Beijing Winter Olympics
- 【云原生 | 从零开始学Kubernetes】三、Kubernetes集群管理工具kubectl
- Ads learning record (lna_atf54143)
- Some errors in configuring the environment
- Shape template matching based on Halcon learning [vi] find_ mirror_ dies. Hdev routine
- 找不到实时聊天软件?给你推荐电商企业都在用的!
- Imx6ull bare metal development learning 1-assembly lit LED
- [trio basic tutorial 16 from introduction to proficiency] UDP communication test supplement
- [trio basic tutorial 17 from getting started to mastering] set up and connect the trio motion controller and input the activation code
- UEFI development learning 4 - getting to know variable services
猜你喜欢
H264 (I) i/p/b frame gop/idr/ and other parameters
PMSM dead time compensation
研究發現,跨境電商客服系統都有這五點功能!
UEFI development learning 3 - create UEFI program
【云原生 | 从零开始学Kubernetes】三、Kubernetes集群管理工具kubectl
Ten thousand words detailed eight sorting must read (code + dynamic diagram demonstration)
C, Numerical Recipes in C, solution of linear algebraic equations, LU decomposition source program
Network port usage
C # joint configuration with Halcon
Compilation warning solution sorting in Quartus II
随机推荐
My-basic application 2: my-basic installation and operation
Network communication model -- Network OSI tcp/ip layering
Improve lighting C program
Record the torch encountered by win10 cuda. is_ False problem in available()
A simple method to prove 1/t Fourier transform
Soem EtherCAT source code analysis I (data type definition)
Halcon's practice based on shape template matching [1]
Define in and define out
PMSM dead time compensation
Programming knowledge -- assembly knowledge
C WinForm [get file path -- traverse folder pictures] - practical exercise 6
研究發現,跨境電商客服系統都有這五點功能!
Shape template matching based on Halcon learning [v] find_ cocoa_ packages_ max_ deformation. Hdev routine
[trio basic from introduction to mastery tutorial 20] trio calculates the arc center and radius through three points of spatial arc
How to select conductive slip ring
Detailed explanation of SQL server stored procedures
Nb-iot technical summary
研究发现,跨境电商客服系统都有这五点功能!
Communication standard -- communication protocol
Compilation warning solution sorting in Quartus II