SIZEOF

8.228 SIZEOF — Size in bytes of an expression

Description:
SIZEOF(X) calculates the number of bytes of storage the expression X occupies.
Standard:
GNU extension
Class:
Inquiry function
Syntax:
N = SIZEOF(X)
Arguments:
X The argument shall be of any type, rank or shape.
Return value:
The return value is of type integer and of the system-dependent kind C_SIZE_T (from the ISO_C_BINDING module). Its value is the number of bytes occupied by the argument. If the argument has the POINTER attribute, the number of bytes of the storage area pointed to is returned. If the argument is of a derived type with POINTER or ALLOCATABLE components, the return value does not account for the sizes of the data pointed to by these components. If the argument is polymorphic, the size according to the declared type is returned. The argument may not be a procedure or procedure pointer.
Example:
integer :: i
real :: r, s(5)
print *, (sizeof(s)/sizeof(r) == 5)
end

The example will print .TRUE. unless you are using a platform where default REAL variables are unusually padded.

See also:
C_SIZEOF, STORAGE_SIZE

© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-4.9.3/gfortran/SIZEOF.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部