Skip to content

Commit

Permalink
Merge #257
Browse files Browse the repository at this point in the history
257: support: use deprecated instead of warning attribute r=ppannuto a=luismarques

Clang support for the warning attribute has just landed but it isn't compatible with this kind of usage, as it requires that the original
declaration be annotated with the same attribute. The warning attribute is also meant not to trigger when the use of the warned about symbol is eliminated through code optimizations, which isn't the point here. We can use the deprecated attribute instead, solving these issues.

Co-authored-by: Luís Marques <luismarques@lowrisc.org>
  • Loading branch information
bors[bot] and luismarques committed Aug 27, 2021
2 parents f072d67 + 159763b commit f69fec5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions support/warning_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
#ifdef __cplusplus
extern "C" {

__attribute__((warning ("prefer snprintf over sprintf")))
__attribute__((deprecated ("prefer snprintf over sprintf")))
int sprintf(char * str, const char * format, ...);

__attribute__((warning ("prefer vsnprintf over vsprintf")))
__attribute__((deprecated ("prefer vsnprintf over vsprintf")))
int vsprintf(char * str, const char * format, va_list ap);

}
#else // !defined __cplusplus

__attribute__((warning ("prefer snprintf over sprintf")))
__attribute__((deprecated ("prefer snprintf over sprintf")))
int sprintf(char * restrict str, const char * restrict format, ...);

__attribute__((warning ("prefer vsnprintf over vsprintf")))
__attribute__((deprecated ("prefer vsnprintf over vsprintf")))
int vsprintf(char * restrict str, const char * restrict format, va_list ap);

#endif // __cplusplus
Expand Down

0 comments on commit f69fec5

Please sign in to comment.