Skip to content

Commit 73f5217

Browse files
committed
Only use __attribute__((format(printf..))) in GNUC
This was causing the Windows builds to fail in Visual Studio.
1 parent fa13e2a commit 73f5217

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

source/examples/vulkan/vk_color_cube/vk_util.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828

2929
#include <vulkan/vulkan.h>
3030

31+
#ifdef __GNUC__
32+
#define GPA_ATTRIBUTE_PRINTF(fmt, args) __attribute__((format(printf, fmt, args)))
33+
#else
34+
#define GPA_ATTRIBUTE_PRINTF(fmg, args)
35+
#endif
36+
3137
#define VK_MODULE_FUNC(X) \
3238
X(vkEnumerateInstanceExtensionProperties) \
3339
X(vkEnumerateInstanceLayerProperties) \
@@ -134,7 +140,7 @@ namespace AMDVulkanDemoVkUtils
134140
//
135141
/// @param [in] format printf style format string
136142
/// @param [in] ... arguments to format string, if any
137-
void Log(const char *format, ...) __attribute__((format(printf, 1, 2)));
143+
void Log(const char* format, ...) GPA_ATTRIBUTE_PRINTF(1, 2);
138144

139145
extern bool are_vk_entry_points_initialized; ///< Flag indicating the initialization status of vulkan entry points.
140146

source/gpu_perf_api_common/gpa_version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//==============================================================================
2-
// Copyright (c) 2016-2022 Advanced Micro Devices, Inc. All rights reserved.
2+
// Copyright (c) 2016-2023 Advanced Micro Devices, Inc. All rights reserved.
33
/// @author AMD Developer Tools Team
44
/// @file
55
/// @brief Macros used for defining GPUPerfAPI version.
@@ -34,7 +34,7 @@
3434

3535
#define AMDT_PROJECT_SUFFIX_STR GPA_VERSION_STRING(AMDT_PROJECT_SUFFIX) ///< Macro for project suffix string.
3636

37-
#define GPA_COPYRIGHT_CURRENT_YEAR 2022 ///< Macro for current year.
37+
#define GPA_COPYRIGHT_CURRENT_YEAR 2023 ///< Macro for current year.
3838

3939
#define GPA_COPYRIGHT_STR \
4040
"Copyright (c) 2010-" GPA_VERSION_STRING(GPA_COPYRIGHT_CURRENT_YEAR) " Advanced Micro Devices, Inc. All rights reserved." ///< Macro for copyright string.

source/gpu_perf_api_common/logging.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//==============================================================================
2-
// Copyright (c) 2016-2021 Advanced Micro Devices, Inc. All rights reserved.
2+
// Copyright (c) 2016-2023 Advanced Micro Devices, Inc. All rights reserved.
33
/// @author AMD Developer Tools Team
44
/// @file
55
/// @brief Logging utility.
@@ -53,6 +53,12 @@
5353
#define TRACE_PRIVATE_FUNCTION_WITH_ARGS(func, ...) ///< Macro used for tracing private function with parameters.
5454
#endif // trace functions.
5555

56+
#ifdef __GNUC__
57+
#define GPA_ATTRIBUTE_PRINTF(fmt, args) __attribute__((format(printf, fmt, args)))
58+
#else
59+
#define GPA_ATTRIBUTE_PRINTF(fmg, args)
60+
#endif
61+
5662
/// @brief Internal GPA logger function.
5763
///
5864
/// @param [in] log_type Logging type.
@@ -103,7 +109,7 @@ class GpaLogger : public TSingleton<GpaLogger>
103109
}
104110
}
105111

106-
void Logf(GpaLoggingType type, const char* msg_fmt, ...) __attribute__((format(printf, 3, 4)))
112+
void Logf(GpaLoggingType type, const char* msg_fmt, ...) GPA_ATTRIBUTE_PRINTF(3, 4)
107113
{
108114
va_list args;
109115
va_start(args, msg_fmt);
@@ -114,7 +120,7 @@ class GpaLogger : public TSingleton<GpaLogger>
114120
/// @brief Logs an error message.
115121
///
116122
/// @param [in] msg_fmt The message to format and pass along.
117-
inline void LogError(const char* msg_fmt, ...) __attribute__((format(printf, 2, 3)))
123+
inline void LogError(const char* msg_fmt, ...) GPA_ATTRIBUTE_PRINTF(2, 3)
118124
{
119125
va_list args;
120126
va_start(args, msg_fmt);
@@ -125,7 +131,7 @@ class GpaLogger : public TSingleton<GpaLogger>
125131
/// @brief Logs an informational message.
126132
///
127133
/// @param [in] msg_fmt The message to format and pass along.
128-
inline void LogMessage(const char* msg_fmt, ...) __attribute__((format(printf, 2, 3)))
134+
inline void LogMessage(const char* msg_fmt, ...) GPA_ATTRIBUTE_PRINTF(2, 3)
129135
{
130136
va_list args;
131137
va_start(args, msg_fmt);
@@ -136,7 +142,7 @@ class GpaLogger : public TSingleton<GpaLogger>
136142
/// @brief Logs a trace message.
137143
///
138144
/// @param [in] msg_fmt The message to format and pass along.
139-
inline void LogTrace(const char* msg_fmt, ...) __attribute__((format(printf, 2, 3)))
145+
inline void LogTrace(const char* msg_fmt, ...) GPA_ATTRIBUTE_PRINTF(2, 3)
140146
{
141147
va_list args;
142148
va_start(args, msg_fmt);
@@ -147,7 +153,7 @@ class GpaLogger : public TSingleton<GpaLogger>
147153
/// @brief Logs a formatted message in internal builds; does nothing in release.
148154
///
149155
/// @param [in] msg_fmt The message to format and pass along.
150-
void LogDebugMessage(const char* msg_fmt, ...) __attribute__((format(printf, 2, 3)))
156+
void LogDebugMessage(const char* msg_fmt, ...) GPA_ATTRIBUTE_PRINTF(2, 3)
151157
{
152158
va_list args;
153159
va_start(args, msg_fmt);
@@ -158,7 +164,7 @@ class GpaLogger : public TSingleton<GpaLogger>
158164
/// @brief Logs a formatted error message in debug builds; does nothing in release.
159165
///
160166
/// @param [in] msg_fmt The message to format and pass along.
161-
void LogDebugError(const char* msg_fmt, ...) __attribute__((format(printf, 2, 3)))
167+
void LogDebugError(const char* msg_fmt, ...) GPA_ATTRIBUTE_PRINTF(2, 3)
162168
{
163169
va_list args;
164170
va_start(args, msg_fmt);
@@ -169,7 +175,7 @@ class GpaLogger : public TSingleton<GpaLogger>
169175
/// @brief Logs a formatted error message in debug builds; does nothing in release.
170176
///
171177
/// @param [in] msg_fmt The message to format and pass along.
172-
void LogDebugTrace(const char* msg_fmt, ...) __attribute__((format(printf, 2, 3)))
178+
void LogDebugTrace(const char* msg_fmt, ...) GPA_ATTRIBUTE_PRINTF(2, 3)
173179
{
174180
va_list args;
175181
va_start(args, msg_fmt);
@@ -180,7 +186,7 @@ class GpaLogger : public TSingleton<GpaLogger>
180186
/// @brief Logs a formatted message in internal builds; does nothing in public builds.
181187
///
182188
/// @param [in] msg_fmt The message to format and pass along.
183-
void LogDebugCounterDefs(const char* msg_fmt, ...) __attribute__((format(printf, 2, 3)))
189+
void LogDebugCounterDefs(const char* msg_fmt, ...) GPA_ATTRIBUTE_PRINTF(2, 3)
184190
{
185191
va_list args;
186192
va_start(args, msg_fmt);

0 commit comments

Comments
 (0)