Skip to content

pragma __builtin_warn_bad_printf_format

IsaacShelton edited this page Nov 13, 2022 · 3 revisions

pragma __builtin_warn_bad_printf_format

pragma __builtin_warn_bad_printf_format is a pragma directive that's used to mark printf-like functions.

Functions marked will have their format argument and variadic arguments checked at compile-time.

Format Checking

The format is checked against the format used by the standard printf(String, ...) function from 2.7/terminal.adept.

Although it's similar to printf(*ubyte, ...), the format of printf(String, ...) isn't completely the same!

Requirements

  • The marked function must have an argument named format that is of type String
  • The marked function must be variadic and use Adept-style varargs
  • The format argument should be the last argument before the variadic arguments

Example Usage

pragma __builtin_warn_bad_printf_format
func myPrintfToFile(file *FILE, format String, arguments ...) int {
    
}
Clone this wiki locally