-2

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?

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261

2 Answers2

0

Quoting C11, chapter 6.4.4.1, Integer constants

Syntax

integer-constant:
decimal-constant integer-suffix opt

integer-suffix:
unsigned-suffix long-suffixopt
unsigned-suffix long-long-suffix
long-suffix unsigned-suffixopt
long-long-suffix unsigned-suffixopt

long-suffix: one of
l L

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.

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261
0

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).

Community
  • 1
  • 1
cadaniluk
  • 15,027
  • 2
  • 39
  • 67