Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does a function have any storage class in C Language?

Does a function have any storage class in C Language?

like image 523
msc Avatar asked Sep 01 '16 07:09

msc


People also ask

What is the default storage class for function in C?

auto: This is the default storage class for all the variables declared inside a function or a block. Hence, the keyword auto is rarely used while writing programs in C language. Auto variables can be only accessed within the block/function they have been declared and not outside them (which defines their scope).

Which is not storage class in C?

Which of the following is not a storage class specifier in C? Explanation: volatile is not a storage class specifier.

Can a function be declared with a static storage class in C?

You can use either the static or the extern storage-class specifier in function declarations. Functions always have global lifetimes. Function declarations at the internal level have the same meaning as function declarations at the external level.


1 Answers

The answer is no. According to http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf (draft of C99) and http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf (draft of C11):

6.2.4 Storage durations of objects

1 An object has a storage duration that determines its lifetime.

Functions aren't objects, so they have no storage.

6.2.2 Linkages of identifiers

3 If the declaration of a file scope identifier for an object or a function contains the storage-class specifier static, the identifier has internal linkage.

This says that static applied to a function affects its linkage (there is no storage it could apply to).

like image 122
melpomene Avatar answered Oct 13 '22 10:10

melpomene