当前位置:网站首页>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】
边栏推荐
- Some tips for using source insight (solve the problem of selecting all)
- [professional literacy] specific direction of analog integrated circuits
- Baiwen 7-day smart home learning experience of Internet of things
- Hardware and software solution of FPGA key chattering elimination
- Drive LED -- GPIO control
- [trio basic tutorial 17 from getting started to mastering] set up and connect the trio motion controller and input the activation code
- C WinForm [realize the previous and next selection pictures] - practice 7
- Random function usage notes
- Connection mode - bridge and net
- Wifi-802.11 negotiation rate table
猜你喜欢
[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication
Volatile of C language
Altium designer 19.1.18 - clear information generated by measuring distance
VESC Benjamin test motor parameters
Halcon's practice based on shape template matching [2]
Altium designer 19.1.18 - Import frame
Altium designer 19.1.18 - change the transparency of copper laying
Shape template matching based on Halcon learning [viii] PM_ multiple_ models. Hdev routine
LED display equipment records of the opening ceremony of the Beijing Winter Olympics
C WinForm [change the position of the form after running] - Practical Exercise 4
随机推荐
MLPerf Training v2.0 榜单发布,在同等GPU配置下百度飞桨性能世界第一
Global and Chinese markets for medical oxygen machines 2022-2028: Research Report on technology, participants, trends, market size and share
Live555 RTSP audio and video streaming summary (II) modify RTSP server streaming URL address
Can't find real-time chat software? Recommend to you what e-commerce enterprises are using!
Record the opening ceremony of Beijing Winter Olympics with display equipment
Global and Chinese market of urban rail connectors 2022-2028: Research Report on technology, participants, trends, market size and share
How to select conductive slip ring
WiFi wpa_ Detailed description of supplicant hostpad interface
Global and Chinese market of resistivity meter 2022-2028: Research Report on technology, participants, trends, market size and share
C language enhancement -- pointer
Some thoughts on extracting perspectives from ealfa and Ebeta
[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...)
Gradle composite construction
[tutorial 15 of trio basic from introduction to proficiency] trio free serial communication
Altium designer 19.1.18 - hide the fly line of a network
Detailed explanation of SQL server stored procedures
[trio basic from introduction to mastery tutorial 20] trio calculates the arc center and radius through three points of spatial arc
Win10 shortcut key
Matlab2018b problem solving when installing embedded coder support package for stmicroelectronic
【论文阅读】2022年最新迁移学习综述笔注(Transferability in Deep Learning: A Survey)