Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
dmd.chkformat
Check the arguments to printf and scanf against the format string.
Authors:
License:
Source chkformat.d
Documentation https://dlang.org/phobos/dmd_chkformat.html
- bool
checkPrintfFormat
(const ref Locloc
, scope const char[]format
, scope Expression[]args
, boolisVa_list
, ErrorSinkeSink
); - Check that arguments to a printf format string are compatible with that string. Issue errors for incompatibilities.Follows the C99 specification for printf. Takes a generous, rather than strict, view of compatiblity. For example, an unsigned value can be formatted with a signed specifier. Diagnosed incompatibilities are:
- incompatible sizes which will cause argument misalignment
- deferencing arguments that are not pointers
- insufficient number of arguments
- struct arguments
- array and slice arguments
- non-pointer arguments to s specifier
- non-standard formats
- undefined behavior per C99
Parameters:Loc loc
location for error messages char[] format
format string Expression[] args
arguments to match with format string bool isVa_list
if a "v" function (format check only) ErrorSink eSink
where the error messages go Returns:true if errors occurredReferences C99 7.19.6.1 https://www.cplusplus.com/reference/cstdio/printf/
- bool
checkScanfFormat
(const ref Locloc
, scope const char[]format
, scope Expression[]args
, boolisVa_list
, ErrorSinkeSink
); - Check that arguments to a scanf format string are compatible with that string. Issue errors for incompatibilities.Follows the C99 specification for scanf. Takes a generous, rather than strict, view of compatiblity. For example, an unsigned value can be formatted with a signed specifier. Diagnosed incompatibilities are:
- incompatible sizes which will cause argument misalignment
- deferencing arguments that are not pointers
- insufficient number of arguments
- struct arguments
- array and slice arguments
- non-standard formats
- undefined behavior per C99
Parameters:Loc loc
location for error messages char[] format
format string Expression[] args
arguments to match with format string bool isVa_list
if a "v" function (format check only) ErrorSink eSink
where the error messages go Returns:true if errors occurredReferences C99 7.19.6.2 https://www.cplusplus.com/reference/cstdio/scanf/
Copyright © 1999-2024 by the D Language Foundation | Page generated by
Ddoc on (no date time)