当前位置:网站首页>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】
边栏推荐
- solver. Learning notes of prototxt file parameters
- Global and Chinese market of quenching furnaces 2022-2028: Research Report on technology, participants, trends, market size and share
- H264 (I) i/p/b frame gop/idr/ and other parameters
- Improve lighting C program
- Hardware and software solution of FPGA key chattering elimination
- C WinForm [view status bar -- statusstrip] - Practice 2
- Gradle复合构建
- Markdown tips
- Relationship between line voltage and phase voltage, line current and phase current
- My-basic application 1: introduction to my-basic parser
猜你喜欢

【云原生 | 从零开始学Kubernetes】三、Kubernetes集群管理工具kubectl
![C WinForm [exit application] - practice 3](/img/25/30c795cc3fa6931eb1d733719d4ad0.jpg)
C WinForm [exit application] - practice 3

Matlab2018b problem solving when installing embedded coder support package for stmicroelectronic

Process communication mode between different hosts -- socket

Beijing Winter Olympics opening ceremony display equipment record 3

导电滑环磨损快的原因

UEFI development learning 3 - create UEFI program
![Correlation based template matching based on Halcon learning [II] find_ ncc_ model_ defocused_ precision. hdev](/img/42/d857452ccfeccbbf1ac34f47e47e2e.jpg)
Correlation based template matching based on Halcon learning [II] find_ ncc_ model_ defocused_ precision. hdev
![Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine](/img/f9/fc4f0bbce36b3c1368d838d723b027.jpg)
Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine

Consul安装
随机推荐
Altium designer learning (I)
Global and Chinese markets of large aperture scintillators 2022-2028: Research Report on technology, participants, trends, market size and share
[trio basic from introduction to mastery tutorial 20] trio calculates the arc center and radius through three points of spatial arc
IEEE access personal contribution experience record
Soem EtherCAT source code analysis II (list of known configuration information)
Basic embedded concepts
Global and Chinese market of core pallets 2022-2028: Research Report on technology, participants, trends, market size and share
General makefile (I) single C language compilation template
C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,LU分解(LU Decomposition)源程序
Live555 RTSP audio and video streaming summary (II) modify RTSP server streaming URL address
Random function usage notes
Volatile of C language
生产中影响滑环质量的因素
solver. Learning notes of prototxt file parameters
1089 insert or merge, including test point 5
[trio basic tutorial 17 from getting started to mastering] set up and connect the trio motion controller and input the activation code
Measurement fitting based on Halcon learning [II] meaure_ pin. Hdev routine
Adaptive filter
【云原生 | 从零开始学Kubernetes】三、Kubernetes集群管理工具kubectl
[trio basic tutorial 16 from introduction to proficiency] UDP communication test supplement