2 * Copyright (C) 2014-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 // macros for gcc, clang & others
12 #ifndef PARAM1_PRINTF_FORMAT
14 // for use in functions that take printf format string as first parameter and additional printf parameters as second parameter
15 // for example: int myprintf(const char* format, ...) PARAM1_PRINTF_FORMAT;
16 #define PARAM1_PRINTF_FORMAT __attribute__((format(printf,1,2)))
18 // for use in functions that take printf format string as second parameter and additional printf parameters as third parameter
19 // for example: bool log_string(int logLevel, const char* format, ...) PARAM2_PRINTF_FORMAT;
20 // note: all non-static class member functions take pointer to class object as hidden first parameter
21 #define PARAM2_PRINTF_FORMAT __attribute__((format(printf,2,3)))
23 // for use in functions that take printf format string as third parameter and additional printf parameters as fourth parameter
24 // note: all non-static class member functions take pointer to class object as hidden first parameter
25 // for example: class A { bool log_string(int logLevel, const char* functionName, const char* format, ...) PARAM3_PRINTF_FORMAT; }
26 #define PARAM3_PRINTF_FORMAT __attribute__((format(printf,3,4)))
28 // for use in functions that take printf format string as fourth parameter and additional printf parameters as fifth parameter
29 // note: all non-static class member functions take pointer to class object as hidden first parameter
30 // for example: class A { bool log_string(int logLevel, const char* functionName, int component, const char* format, ...) PARAM4_PRINTF_FORMAT; }
31 #define PARAM4_PRINTF_FORMAT __attribute__((format(printf,4,5)))
33 #define PARAM1_PRINTF_FORMAT
34 #define PARAM2_PRINTF_FORMAT
35 #define PARAM3_PRINTF_FORMAT
36 #define PARAM4_PRINTF_FORMAT
38 #endif // PARAM1_PRINTF_FORMAT
41 // VC check parameters only when "Code Analysis" is called
42 #ifndef PRINTF_FORMAT_STRING
46 // for use in any function that take printf format string and parameters
47 // for example: bool log_string(int logLevel, PRINTF_FORMAT_STRING const char* format, ...);
48 #define PRINTF_FORMAT_STRING _In_z_ _Printf_format_string_
50 // specify that parameter must be zero-terminated string
51 // for example: void SetName(IN_STRING const char* newName);
52 #define IN_STRING _In_z_
54 // specify that parameter must be zero-terminated string or NULL
55 // for example: bool SetAdditionalName(IN_OPT_STRING const char* addName);
56 #define IN_OPT_STRING _In_opt_z_
58 #define PRINTF_FORMAT_STRING
62 #endif // PRINTF_FORMAT_STRING