summaryrefslogtreecommitdiff
path: root/src/stdafx.h
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-05-13 10:00:41 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-05-14 23:22:29 +0200
commitaa5a8fe28a224fd581b6053e4a5ce38f3e1a9694 (patch)
tree3641fec62fd2f0969ce0ac06b4f7670d7e43c9f4 /src/stdafx.h
parent297d6e20bf0467d2a42e49bee291829ce3bb7c58 (diff)
downloadopenttd-aa5a8fe28a224fd581b6053e4a5ce38f3e1a9694.tar.xz
Codechange: use thread safe time functions
Functions like localtime, gmtime and asctime are not thread safe as they (might) reuse the same buffer. So use the safer _s/_r variant for localtime and gmtime, and use strftime in favour of asctime.
Diffstat (limited to 'src/stdafx.h')
-rw-r--r--src/stdafx.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/stdafx.h b/src/stdafx.h
index 937c053f2..319d94edf 100644
--- a/src/stdafx.h
+++ b/src/stdafx.h
@@ -129,6 +129,7 @@
/* Warn about functions using 'printf' format syntax. First argument determines which parameter
* is the format string, second argument is start of values passed to printf. */
# define WARN_FORMAT(string, args) __attribute__ ((format (printf, string, args)))
+# define WARN_TIME_FORMAT(string) __attribute__ ((format (strftime, string, 0)))
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
# define FINAL final
# else
@@ -157,6 +158,7 @@
# define NORETURN
# define CDECL
# define WARN_FORMAT(string, args)
+# define WARN_TIME_FORMAT(string)
# define FINAL
# define FALLTHROUGH
# include <malloc.h>
@@ -205,6 +207,7 @@
# define CDECL _cdecl
# define WARN_FORMAT(string, args)
+# define WARN_TIME_FORMAT(string)
# define FINAL final
/* fallthrough attribute, VS 2017 */