diff --git a/calma/calma.h b/calma/calma.h index d5f6363e..422cd344 100644 --- a/calma/calma.h +++ b/calma/calma.h @@ -65,7 +65,7 @@ extern bool CalmaWrite(CellDef *rootDef, FILE *f); extern void CalmaReadFile(FILETYPE file, char *filename); extern void CalmaTechInit(void); extern bool CalmaGenerateArray(FILE *f, TileType type, int llx, int lly, int pitch, int cols, int rows); -extern void CalmaReadError(char *format, ...); +extern void CalmaReadError(char *format, ...) ATTR_FORMAT_PRINTF_1; /* C99 compat */ extern void calmaDelContacts(void); diff --git a/cif/CIFread.h b/cif/CIFread.h index c5400391..39fdb0e3 100644 --- a/cif/CIFread.h +++ b/cif/CIFread.h @@ -188,8 +188,8 @@ extern int CIFEdgeDirection(CIFPath *first, CIFPath *last); /* Variable argument procedures require complete prototype */ -extern void CIFReadError(char *format, ...); -extern void CIFReadWarning(char *format, ...); +extern void CIFReadError(char *format, ...) ATTR_FORMAT_PRINTF_1; +extern void CIFReadWarning(char *format, ...) ATTR_FORMAT_PRINTF_1; /* Variables shared by the CIF-reading modules, see CIFreadutils.c * for more details: diff --git a/lef/lefInt.h b/lef/lefInt.h index 21e2c88b..c91e8533 100644 --- a/lef/lefInt.h +++ b/lef/lefInt.h @@ -162,8 +162,8 @@ void LefReadLayerSection(); LefMapping *defMakeInverseLayerMap(); -void LefError(int, char *, ...); /* Variable argument procedure requires */ - /* parameter list. */ +/* Variable argument procedure requires parameter list. */ +void LefError(int, char *, ...) ATTR_FORMAT_PRINTF_2; /* C99 compat */ extern void LefRead(); diff --git a/textio/textio.h b/textio/textio.h index aa3e5fff..1158b7d9 100644 --- a/textio/textio.h +++ b/textio/textio.h @@ -68,10 +68,10 @@ extern void TxUseMore(); extern void TxStopMore(); /* printing procedures with variable arguments lists */ -extern void TxError(char *, ...); +extern void TxError(char *, ...) ATTR_FORMAT_PRINTF_1; extern void TxErrorV(char *, va_list args); -extern void TxPrintf(char *, ...); -extern char *TxPrintString(char *, ...); +extern void TxPrintf(char *, ...) ATTR_FORMAT_PRINTF_1; +extern char *TxPrintString(char *, ...) ATTR_FORMAT_PRINTF_1; /* input procedures */ extern char *TxGetLinePrompt(); diff --git a/textio/textioInt.h b/textio/textioInt.h index 83de8c62..7075a979 100644 --- a/textio/textioInt.h +++ b/textio/textioInt.h @@ -52,7 +52,7 @@ extern bool TxGetInputEvent(); /* Routines with variable argument lists */ -extern void txFprintfBasic(FILE *, ...); +extern void txFprintfBasic(FILE *, const char *fmt, ...) ATTR_FORMAT_PRINTF_2; /* C99 compat */ void txCommandsInit(); diff --git a/textio/txOutput.c b/textio/txOutput.c index 7aec132e..d1195ede 100644 --- a/textio/txOutput.c +++ b/textio/txOutput.c @@ -76,13 +76,11 @@ static bool txPrintFlag = TRUE; */ void -txFprintfBasic(FILE *f, ...) +txFprintfBasic(FILE *f, const char *fmt, ...) { va_list args; - char *fmt; - va_start(args, f); - fmt = va_arg(args, char *); + va_start(args, fmt); Vfprintf(f, fmt, args); va_end(args); } diff --git a/utils/magic.h b/utils/magic.h index 0dcda8e9..8f905edf 100644 --- a/utils/magic.h +++ b/utils/magic.h @@ -168,6 +168,16 @@ extern char AbortMessage[]; #define PaLockZOpen PaLockOpen #endif +/* ------------ modern compiler support -------------------------------- */ + +#if defined(__GNUC__) || defined(__clang__) + #define ATTR_FORMAT_PRINTF_1 __attribute__((format (printf,1,2))) + #define ATTR_FORMAT_PRINTF_2 __attribute__((format (printf,2,3))) +#else + #define ATTR_FORMAT_PRINTF_1 /* */ + #define ATTR_FORMAT_PRINTF_2 /* */ +#endif + /* ---------------- Start of Machine Configuration Section ----------------- */ /* ------- Configuration: Handle Missing Routines/Definitions ------- */ diff --git a/utils/tech.h b/utils/tech.h index e2cd8ff0..3bb3f9f3 100644 --- a/utils/tech.h +++ b/utils/tech.h @@ -51,7 +51,7 @@ extern bool TechOverridesDefault; /* Set TRUE if technology was specified on /* ----------------- Exported procedures ---------------- */ -extern void TechError(char *, ...); +extern void TechError(char *, ...) ATTR_FORMAT_PRINTF_1; extern void TechAddClient(); extern void TechAddAlias();