当前位置:网站首页>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】
边栏推荐
- Shape template matching based on Halcon learning [v] find_ cocoa_ packages_ max_ deformation. Hdev routine
- Global and Chinese markets for medical oxygen machines 2022-2028: Research Report on technology, participants, trends, market size and share
- 生产中影响滑环质量的因素
- Global and Chinese markets of large aperture scintillators 2022-2028: Research Report on technology, participants, trends, market size and share
- The firmware of the connected j-link does not support the following memory access
- C WinForm [exit application] - practice 3
- Live555 push RTSP audio and video stream summary (III) flower screen problem caused by pushing H264 real-time stream
- Altium designer 19.1.18 - hide the fly line of a network
- C WinForm [display real-time time in the status bar] - practical exercise 1
- Measurement fitting based on Halcon learning [II] meaure_ pin. Hdev routine
猜你喜欢

如何将EasyCVR平台RTSP接入的设备数据迁移到EasyNVR中?

PMSM dead time compensation

Carrier period, electrical speed, carrier period variation

C language enhancement -- pointer

The printer encountered an abnormal configuration problem 0x8007007e (win10)

Hardware and software solution of FPGA key chattering elimination

Drive LED -- GPIO control

Win10 shortcut key

UEFI development learning 3 - create UEFI program

Embedded composition and route
随机推荐
Altium designer 19.1.18 - clear information generated by measuring distance
Global and Chinese markets for anesthesia, breathing and sleep apnea devices 2022-2028: Research Report on technology, participants, trends, market size and share
Random function usage notes
Network communication process
The printer encountered an abnormal configuration problem 0x8007007e (win10)
C WinForm [display real-time time in the status bar] - practical exercise 1
Halcon's practice based on shape template matching [2]
My-basic application 1: introduction to my-basic parser
OLED 0.96 inch test
Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine
Some errors in configuring the environment
Sql Server的存儲過程詳解
Connection mode - bridge and net
C WinForm [view status bar -- statusstrip] - Practice 2
Basic information commands and functions of kernel development
C # joint configuration with Halcon
Process communication mode between different hosts -- socket
Gradle composite construction
Pointnet++ classification practice
[popular science] some interesting things that I don't know whether they are useful or not