ILD

Arithmetic on void- and Function-Pointers
作者:YUAN JIANPENG 邮箱:yuanjp@hust.edu.cn
发布时间:2018-7-6 站点:Inside Linux Development

GCC支持void指针和函数指针的加减运算。void和函数的size为1。允许对void和函数类型执行sizeof,其返回1.

选项-Wpointer-arith产生一个警告,如果这些扩展被使用的话。

In GNU C, addition and subtraction operations are supported on pointers to void and on

pointers to functions. This is done by treating the size of a void or of a function as 1.

A consequence of this is that sizeof is also allowed on void and on function types, and

returns 1.

The option ‘-Wpointer-arith’ requests a warning if these extensions are used

Copyright © linuxdev.cc 2017-2024. Some Rights Reserved.