Reputation: 1559
Per cppreference.com the length modifier %L is valid only for float types. But modern GNU compiler & library seems to accept it also for integers as synonym of %ll (long long). Is there a chance that cppreference mistakes on this? Or is %L for integers going to become standard in future?
Upvotes: 1
Views: 293
Reputation: 21360
The valid length modifiers are listed in §7.21.6.1 7 of the C11 Standard.
The only mention of L
as a length modifier in the Standard is for long double
types:
L Specifies that a following a, A, e, E, f, F, g, or G conversion specifier applies to a long double argument.
Further, there is no mention of this in §7.31 Future Library Directions:
7.31.11 Input/output < stdio.h >
1 Lowercase letters may be added to the conversion specifiers and length modifiers in fprintf and fscanf. Other characters may be used in extensions.
2 The use of ungetc on a binary stream where the file position indicator is zero prior to the call is an obsolescent feature.
And, the same use of L
holds in the POSIX Standard: L
is a length modifier to be used with long double
types only.
Upvotes: 3
Reputation:
From the latest C11 draft N1570, §7.21.6.1 section 7:
L
-- Specifies that a followinga
,A
,e
,E
,f
,F
,g
, orG
conversion specifier applies to along double
argument.
So your source is correct, L
as a length modifier is only defined for floating point conversions. I wouldn't expect this to change in future versions, as there's simply no need. Just use l
and ll
as appropriate.
Upvotes: 4