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.
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