I am reading old c code(1991), and i don't understand something, there is a define like:
#define SLEEP_MIN (SLEEP_SEC*60L)
SLEEP_SEC defined as 60, what the 60L means?
I am reading old c code(1991), and i don't understand something, there is a define like:
#define SLEEP_MIN (SLEEP_SEC*60L)
SLEEP_SEC defined as 60, what the 60L means?
Quoting C11, chapter 6.4.4.1, Integer constants
Syntax
integer-constant:
decimal-constant integer-suffix optinteger-suffix:
unsigned-suffix long-suffixopt
unsigned-suffix long-long-suffix
long-suffix unsigned-suffixopt
long-long-suffix unsigned-suffixoptlong-suffix: one of
lL
So, 60L is making 60 to a type of long.
Related: Why the L is required,
[5] The type of an integer constant is the first of the corresponding list in which its value can be represented.
So, withouth the L suffix, 60 will be treated as int.
It is an integer literal.
In particular, the L stands for a literal of type long.
As an integer literal is of type int by default (or not), the L suffix explicitly says that the literal is of type long, effectively making SLEEP_MIN a long (as far as a macro can have a type).