当前位置:网站首页>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】
边栏推荐
- Network port usage
- [popular science] some interesting things that I don't know whether they are useful or not
- The browser cannot access Baidu
- Soem EtherCAT source code analysis I (data type definition)
- Altium designer 19.1.18 - clear information generated by measuring distance
- Arduino uses nrf24l01+ communication
- UEFI development learning 2 - running ovmf in QEMU
- 1089 Insert or Merge 含测试点5
- Ads learning record (lna_atf54143)
- Relationship between line voltage and phase voltage, line current and phase current
猜你喜欢

Embedded composition and route

Consul installation

Process communication mode between different hosts -- socket

Basic embedded concepts

Shell script basic syntax
![[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication](/img/08/7f28008a4aa999650998ba8dee5d8e.jpg)
[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication

Arduino uses nrf24l01+ communication

C # joint configuration with Halcon

Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)

Class of color image processing based on Halcon learning_ ndim_ norm. hdev
随机推荐
Shell脚本基本语法
[trio basic from introduction to mastery tutorial 20] trio calculates the arc center and radius through three points of spatial arc
Sql Server的存储过程详解
Communication standard -- communication protocol
[trio basic tutorial 17 from getting started to mastering] set up and connect the trio motion controller and input the activation code
如何进行导电滑环选型
[untitled] record the visual shock of the Winter Olympics and the introduction of the display screen
Reasons for rapid wear of conductive slip rings
Global and Chinese market of rammers 2022-2028: Research Report on technology, participants, trends, market size and share
如何将EasyCVR平台RTSP接入的设备数据迁移到EasyNVR中?
Explication de la procédure stockée pour SQL Server
Count and sort the occurrence times of specific fields through SQL statements
Beijing Winter Olympics opening ceremony display equipment record 3
Pointnet++ classification practice
Altium designer 19.1.18 - clear information generated by measuring distance
Altium designer learning (I)
How to define guid in AMI code
Create inf module in AMI code
Some errors in configuring the environment
Live555 push RTSP audio and video stream summary (I) cross compilation