[Scummvm-git-logs] scummvm master -> e3d082df659c730b250e980842f6861a45b19470

bluegr bluegr at gmail.com
Wed Jun 2 05:35:34 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e3d082df65 MSVC: Add compiler printf validation


Commit: e3d082df659c730b250e980842f6861a45b19470
    https://github.com/scummvm/scummvm/commit/e3d082df659c730b250e980842f6861a45b19470
Author: SupSuper (supsuper at gmail.com)
Date: 2021-06-02T08:35:31+03:00

Commit Message:
MSVC: Add compiler printf validation

Changed paths:
    backends/midi/timidity.cpp
    base/commandLine.cpp
    common/debug.h
    common/scummsys.h
    common/str.h
    common/textconsole.h


diff --git a/backends/midi/timidity.cpp b/backends/midi/timidity.cpp
index 91665fb452..e67ee6fe2b 100644
--- a/backends/midi/timidity.cpp
+++ b/backends/midi/timidity.cpp
@@ -95,7 +95,7 @@ private:
 	int connect_to_server(const char* hostname, const char* tcp_port);
 
 	/* send command to the server; printf-like; returns reply string */
-	char *timidity_ctl_command(const char *fmt, ...) GCC_PRINTF(2, 3);
+	char *timidity_ctl_command(MSVC_PRINTF const char *fmt, ...) GCC_PRINTF(2, 3);
 
 	/* timidity data socket-related stuff */
 	void timidity_meta_seq(int p1, int p2, int p3);
diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 8b49072092..ae3dd75de8 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -208,7 +208,7 @@ static const char HELP_STRING[] =
 
 static const char *s_appName = "scummvm";
 
-static void NORETURN_PRE usage(const char *s, ...) GCC_PRINTF(1, 2) NORETURN_POST;
+static void NORETURN_PRE usage(MSVC_PRINTF const char *s, ...) GCC_PRINTF(1, 2) NORETURN_POST;
 
 static void usage(const char *s, ...) {
 	char buf[STRINGBUFLEN];
diff --git a/common/debug.h b/common/debug.h
index d300f15ac7..4544a69db6 100644
--- a/common/debug.h
+++ b/common/debug.h
@@ -52,7 +52,7 @@ inline void debugCN(uint32 debugChannels, const char *s, ...) {}
  * Print a debug message to the text console (stdout).
  * Automatically appends a newline.
  */
-void debug(const char *s, ...) GCC_PRINTF(1, 2);
+void debug(MSVC_PRINTF const char *s, ...) GCC_PRINTF(1, 2);
 
 /**
  * Print a debug message to the text console (stdout), but only if
@@ -60,13 +60,13 @@ void debug(const char *s, ...) GCC_PRINTF(1, 2);
  * As a rule of thumb, the more important the message, the lower the level.
  * Automatically appends a newline.
  */
-void debug(int level, const char *s, ...) GCC_PRINTF(2, 3);
+void debug(int level, MSVC_PRINTF const char *s, ...) GCC_PRINTF(2, 3);
 
 /**
  * Print a debug message to the text console (stdout).
  * Does not append a newline.
  */
-void debugN(const char *s, ...) GCC_PRINTF(1, 2);
+void debugN(MSVC_PRINTF const char *s, ...) GCC_PRINTF(1, 2);
 
 /**
  * Print a debug message to the text console (stdout), but only if
@@ -74,7 +74,7 @@ void debugN(const char *s, ...) GCC_PRINTF(1, 2);
  * As a rule of thumb, the more important the message, the lower the level.
  * Does not append a newline.
  */
-void debugN(int level, const char *s, ...) GCC_PRINTF(2, 3);
+void debugN(int level, MSVC_PRINTF const char *s, ...) GCC_PRINTF(2, 3);
 
 /**
  * Print a debug message to the text console (stdout), but only if
@@ -88,7 +88,7 @@ void debugN(int level, const char *s, ...) GCC_PRINTF(2, 3);
  * @param debugChannels Bitfield of channels to check against.
  * @param s             Message to print.
  */
-void debugC(int level, uint32 debugChannels, const char *s, ...) GCC_PRINTF(3, 4);
+void debugC(int level, uint32 debugChannels, MSVC_PRINTF const char *s, ...) GCC_PRINTF(3, 4);
 
 /**
  * Print a debug message to the text console (stdout), but only if
@@ -103,7 +103,7 @@ void debugC(int level, uint32 debugChannels, const char *s, ...) GCC_PRINTF(3, 4
  * @param s             Message to print.
  *
  */
-void debugCN(int level, uint32 debugChannels, const char *s, ...) GCC_PRINTF(3, 4);
+void debugCN(int level, uint32 debugChannels, MSVC_PRINTF const char *s, ...) GCC_PRINTF(3, 4);
 
 /**
  * Print a debug message to the text console (stdout), but only if
@@ -114,7 +114,7 @@ void debugCN(int level, uint32 debugChannels, const char *s, ...) GCC_PRINTF(3,
  * @param debugChannels Bitfield of channels to check against.
  * @param s             Message to print.
  */
-void debugC(uint32 debugChannels, const char *s, ...) GCC_PRINTF(2, 3);
+void debugC(uint32 debugChannels, MSVC_PRINTF const char *s, ...) GCC_PRINTF(2, 3);
 
 /**
  * Print a debug message to the text console (stdout), but only if
@@ -125,7 +125,7 @@ void debugC(uint32 debugChannels, const char *s, ...) GCC_PRINTF(2, 3);
  * @param debugChannels Bitfield of channels to check against.
  * @param s             Message to print.
  */
-void debugCN(uint32 debugChannels, const char *s, ...) GCC_PRINTF(2, 3);
+void debugCN(uint32 debugChannels, MSVC_PRINTF const char *s, ...) GCC_PRINTF(2, 3);
 
 #endif
 
diff --git a/common/scummsys.h b/common/scummsys.h
index 79fb7a7791..0dcb43c3d4 100644
--- a/common/scummsys.h
+++ b/common/scummsys.h
@@ -349,6 +349,14 @@
 	#endif
 #endif
 
+#ifndef MSVC_PRINTF
+	#if _MSC_VER > 1400
+		#define MSVC_PRINTF _Printf_format_string_
+	#else
+		#define MSVC_PRINTF
+	#endif
+#endif
+
 #ifndef PACKED_STRUCT
 	#if defined(__GNUC__) || defined(__INTEL_COMPILER)
 		#define PACKED_STRUCT __attribute__((__packed__))
diff --git a/common/str.h b/common/str.h
index ca0a3e886f..8ad41d92e1 100644
--- a/common/str.h
+++ b/common/str.h
@@ -185,7 +185,7 @@ public:
 	 * except that it stores the result in (variably sized) String
 	 * instead of a fixed size buffer.
 	 */
-	static String format(const char *fmt, ...) GCC_PRINTF(1, 2);
+	static String format(MSVC_PRINTF const char *fmt, ...) GCC_PRINTF(1, 2);
 
 	/**
 	 * Print formatted data into a String object. Similar to vsprintf,
diff --git a/common/textconsole.h b/common/textconsole.h
index f99909677d..dc2be2c112 100644
--- a/common/textconsole.h
+++ b/common/textconsole.h
@@ -81,11 +81,11 @@ void setErrorHandler(ErrorHandler handler);
 /**
  * Print an error message to the text console and then terminate the process.
  */
-void NORETURN_PRE error(const char *s, ...) GCC_PRINTF(1, 2) NORETURN_POST;
+void NORETURN_PRE error(MSVC_PRINTF const char *s, ...) GCC_PRINTF(1, 2) NORETURN_POST;
 
 #ifdef DISABLE_TEXT_CONSOLE
 
-inline void warning(const char *s, ...) {}
+inline void warning(MSVC_PRINTF const char *s, ...) GCC_PRINTF(1, 2) {}
 
 #else
 
@@ -95,7 +95,7 @@ inline void warning(const char *s, ...) {}
  * Automatically prepends the text "WARNING: " and appends
  * an exclamation mark and a newline.
  */
-void warning(const char *s, ...) GCC_PRINTF(1, 2);
+void warning(MSVC_PRINTF const char *s, ...) GCC_PRINTF(1, 2);
 
 #endif
 /** @} */




More information about the Scummvm-git-logs mailing list