Added functionality to mark printf() functions for compilers with warning checks, and marked such. Sadly it appears ms_printf is ignored with -pedantic, so we'll need to stop using I32...
This commit is contained in:
parent
ef3352c033
commit
6ffe0a4c99
|
@ -28,9 +28,14 @@ extern "C" {
|
|||
#define uiprivSizetPrintf "zu"
|
||||
#endif
|
||||
|
||||
#include "../sharedbits/printfwarn_header.h"
|
||||
#define uiprivPrintfFunc(decl, fmtpos, appos) sharedbitsPrintfFunc(decl, fmtpos, appos)
|
||||
|
||||
// main.c
|
||||
extern bool uiprivSysInit(void *options, uiInitError *err);
|
||||
extern bool uiprivInitReturnErrorf(uiInitError *err, const char *fmt, ...);
|
||||
uiprivPrintfFunc(
|
||||
extern bool uiprivInitReturnErrorf(uiInitError *err, const char *fmt, ...),
|
||||
2, 3);
|
||||
extern void uiprivSysQueueMain(void (*f)(void *data), void *data);
|
||||
extern bool uiprivCheckInitializedAndThreadImpl(const char *func);
|
||||
#define uiprivCheckInitializedAndThread() uiprivCheckInitializedAndThreadImpl(uiprivFunc)
|
||||
|
@ -49,7 +54,9 @@ extern bool uiprivSysCheckThread(void);
|
|||
#undef sharedbitsPrefix
|
||||
|
||||
// errors.c
|
||||
extern void uiprivInternalError(const char *fmt, ...);
|
||||
uiprivPrintfFunc(
|
||||
extern void uiprivInternalError(const char *fmt, ...),
|
||||
1, 2);
|
||||
enum {
|
||||
uiprivProgrammerErrorNotInitialized, // arguments: uiprivFunc
|
||||
uiprivProgrammerErrorWrongThread, // arguments: uiprivFunc
|
||||
|
@ -63,6 +70,7 @@ enum {
|
|||
uiprivProgrammerErrorRecursiveEventFire, // no arguments
|
||||
uiprivNumProgrammerErrors,
|
||||
};
|
||||
// TODO drop the enum and make the above all format strings
|
||||
extern void uiprivProgrammerError(unsigned int which, ...);
|
||||
extern void uiprivReportError(const char *prefix, const char *msg, const char *suffix, bool internal);
|
||||
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
|
||||
#include "start.h"
|
||||
|
||||
extern void sharedbitsPrefixName(InternalError)(const char *fmt, ...);
|
||||
#include "printfwarn_header.h"
|
||||
sharedbitsPrintfFunc(
|
||||
extern void sharedbitsPrefixName(InternalError)(const char *fmt, ...),
|
||||
1, 2);
|
||||
|
||||
void *sharedbitsPrefixName(Alloc)(size_t n, const char *what)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
// 1 june 2019
|
||||
|
||||
#ifdef __GNUC__
|
||||
#ifdef _WIN32
|
||||
#define sharedbitsPrintfFunc(decl, fmtpos, appos) \
|
||||
decl __attribute__((format(ms_printf, fmtpos, appos)))
|
||||
#else
|
||||
#define sharedbitsPrintfFunc(decl, fmtpos, appos) \
|
||||
decl __attribute__((format(printf, fmtpos, appos)))
|
||||
#endif
|
||||
#else
|
||||
#define sharedbitsPrintfFunc(decl, fmtpos, appos) \
|
||||
decl
|
||||
#endif
|
|
@ -8,12 +8,15 @@
|
|||
#define sharedbitsprivInternalError sharedbitsInternalError
|
||||
#else
|
||||
#define sharedbitsprivInternalError sharedbitsPrefixName(InternalError)
|
||||
#include "printfwarn_header.h"
|
||||
#ifdef sharedbitsStatic
|
||||
sharedbitsStatic
|
||||
#else
|
||||
extern
|
||||
#endif
|
||||
void sharedbitsprivInternalError(const char *fmt, ...);
|
||||
sharedbitsPrintfFunc(
|
||||
void sharedbitsprivInternalError(const char *fmt, ...),
|
||||
1, 2);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -76,5 +76,9 @@ extern void testingprivSetRegisterTest(testingSet **pset, const char *, void (*)
|
|||
#define testingprivExpand(x) x
|
||||
#define testingprivTLogfThen(then, t, ...) ((testingprivTLogfFull(t, __FILE__, __LINE__, __VA_ARGS__)), (then(t)))
|
||||
#define testingprivTLogvfThen(then, t, format, ap) ((testingprivTLogvfFull(t, __FILE__, __LINE__, format, ap)), (then(t)))
|
||||
extern void testingprivTLogfFull(testingT *, const char *, long, const char *, ...);
|
||||
#include "../../sharedbits/printfwarn_header.h"
|
||||
sharedbitsPrintfFunc(
|
||||
extern void testingprivTLogfFull(testingT *, const char *, long, const char *, ...),
|
||||
4, 5);
|
||||
#undef sharedbitsPrintfFunc
|
||||
extern void testingprivTLogvfFull(testingT *, const char *, long, const char *, va_list);
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
// 19 may 2019
|
||||
|
||||
extern void testingprivInternalError(const char *fmt, ...);
|
||||
#include "../../sharedbits/printfwarn_header.h"
|
||||
|
||||
sharedbitsPrintfFunc(
|
||||
extern void testingprivInternalError(const char *fmt, ...),
|
||||
1, 2);
|
||||
|
||||
#define sharedbitsPrefix testingpriv
|
||||
|
||||
|
@ -18,10 +22,14 @@ extern void testingprivInternalError(const char *fmt, ...);
|
|||
#undef sharedbitsPrefix
|
||||
|
||||
extern int testingprivVsnprintf(char *s, size_t n, const char *fmt, va_list ap);
|
||||
extern int testingprivSnprintf(char *s, size_t n, const char *fmt, ...);
|
||||
sharedbitsPrintfFunc(
|
||||
extern int testingprivSnprintf(char *s, size_t n, const char *fmt, ...),
|
||||
3, 4);
|
||||
extern char *testingprivStrdup(const char *s);
|
||||
extern char *testingprivVsmprintf(const char *fmt, va_list ap);
|
||||
extern char *testingprivSmprintf(const char *fmt, ...);
|
||||
sharedbitsPrintfFunc(
|
||||
extern char *testingprivSmprintf(const char *fmt, ...),
|
||||
1, 2);
|
||||
|
||||
// a testingprivOutbuf of NULL writes directly to stdout
|
||||
typedef struct testingprivOutbuf testingprivOutbuf;
|
||||
|
@ -29,6 +37,10 @@ extern testingprivOutbuf *testingprivNewOutbuf(void);
|
|||
extern void testingprivOutbufFree(testingprivOutbuf *o);
|
||||
extern void testingprivOutbufVprintf(testingprivOutbuf *o, const char *fmt, va_list ap);
|
||||
extern void testingprivOutbufVprintfIndented(testingprivOutbuf *o, const char *fmt, va_list ap);
|
||||
extern void testingprivOutbufPrintf(testingprivOutbuf *o, const char *fmt, ...);
|
||||
sharedbitsPrintfFunc(
|
||||
extern void testingprivOutbufPrintf(testingprivOutbuf *o, const char *fmt, ...),
|
||||
2, 3);
|
||||
extern void testingprivOutbufAppendOutbuf(testingprivOutbuf *o, testingprivOutbuf *src);
|
||||
extern const char *testingprivOutbufString(testingprivOutbuf *o);
|
||||
|
||||
#undef sharedbitsPrintfFunc
|
||||
|
|
Loading…
Reference in New Issue