当前位置:网站首页>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】
边栏推荐
- Global and Chinese markets of large aperture scintillators 2022-2028: Research Report on technology, participants, trends, market size and share
- Class of color image processing based on Halcon learning_ ndim_ norm. hdev
- Verilog -- state machine coding method
- Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine
- Network port usage
- [popular science] some interesting things that I don't know whether they are useful or not
- Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)
- Some errors in configuring the environment
- Markdown tips
- Network communication model -- Network OSI tcp/ip layering
猜你喜欢
如何将EasyCVR平台RTSP接入的设备数据迁移到EasyNVR中?
Altium designer learning (I)
C WinForm [view status bar -- statusstrip] - Practice 2
Process communication mode between different hosts -- socket
Reasons for rapid wear of conductive slip rings
[trio basic from introduction to mastery tutorial 20] trio calculates the arc center and radius through three points of spatial arc
C # joint configuration with Halcon
After installing the new version of keil5 or upgrading the JLINK firmware, you will always be prompted about the firmware update
[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication
[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 of core pallets 2022-2028: Research Report on technology, participants, trends, market size and share
How to select conductive slip ring
Shell script basic syntax
Arduino uses nrf24l01+ communication
C # joint configuration with Halcon
Create inf module in AMI code
My-basic application 2: my-basic installation and operation
Semiconductor devices (I) PN junction
[trio basic tutorial 16 from introduction to proficiency] UDP communication test supplement
Global and Chinese market of quenching furnaces 2022-2028: Research Report on technology, participants, trends, market size and share
Some tips for using source insight (solve the problem of selecting all)
Reasons for rapid wear of conductive slip rings
【云原生 | 从零开始学Kubernetes】三、Kubernetes集群管理工具kubectl
Adaptive filter
Detailed explanation of SQL server stored procedures
UEFI development learning series
[professional literacy] core conferences and periodicals in the field of integrated circuits
Global and Chinese markets for flexible endoscopic lithotripsy devices 2022-2028: Research Report on technology, participants, trends, market size and share
PMSM dead time compensation
C, Numerical Recipes in C, solution of linear algebraic equations, LU decomposition source program