add support for [[maybe_unused]] if available
This commit is contained in:
@@ -389,6 +389,14 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */
|
||||
#define FALLTHROUGH [[fallthrough]]
|
||||
/* #warning [[fallthrough]] from C23 */
|
||||
#endif /* __has_c_attribute(fallthrough) */
|
||||
/*
|
||||
* maybe_unused
|
||||
*/
|
||||
#if __has_c_attribute(maybe_unused)
|
||||
#ifndef ATTRUNUSED
|
||||
#define ATTRUNUSED [[maybe_unused]]
|
||||
#endif
|
||||
#endif /* __has_c_attribute(maybe_unused) */
|
||||
#endif /* NH_C >= 202300L */
|
||||
|
||||
/*
|
||||
@@ -416,7 +424,9 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */
|
||||
#define PRINTF_F_PTR(f, v) PRINTF_F(f, v)
|
||||
#endif
|
||||
#if __GNUC__ >= 3
|
||||
#ifndef ATTRUNUSED
|
||||
#define UNUSED __attribute__((unused))
|
||||
#endif
|
||||
#ifndef ATTRNORETURN
|
||||
#ifndef NORETURN
|
||||
#define NORETURN __attribute__((noreturn))
|
||||
@@ -496,6 +506,9 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */
|
||||
#define NH_PRAGMA_MESSAGE 1
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#if !defined(UNUSED) && defined(ATTRUNUSED)
|
||||
#define UNUSED ATTRUNUSED
|
||||
#endif
|
||||
|
||||
/* Fallback implementations */
|
||||
#ifndef PRINTF_F
|
||||
@@ -507,6 +520,9 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */
|
||||
#ifndef UNUSED
|
||||
#define UNUSED
|
||||
#endif
|
||||
#ifndef ATTRUNUSED
|
||||
#define ATTRUNUSED
|
||||
#endif
|
||||
#ifndef FALLTHROUGH
|
||||
#define FALLTHROUGH
|
||||
#endif
|
||||
|
||||
@@ -110,7 +110,7 @@ static char bid[40];
|
||||
|
||||
/* ARGSUSED */
|
||||
void
|
||||
crashreport_init(int argc UNUSED, char *argv[] UNUSED)
|
||||
crashreport_init(int argc, char *argv[])
|
||||
{
|
||||
static int once = 0;
|
||||
if (once++) /* NetHackW.exe calls us twice */
|
||||
@@ -169,6 +169,8 @@ crashreport_init(int argc UNUSED, char *argv[] UNUSED)
|
||||
Strcpy(bid, "unknown");
|
||||
HASH_CLEANUP(ctxp);
|
||||
HASH_PRAGMA_END
|
||||
nhUse(argc);
|
||||
nhUse(argv);
|
||||
}
|
||||
|
||||
#undef HASH_CONTEXTPTR
|
||||
|
||||
@@ -1311,7 +1311,7 @@ extern void objects_globals_init(void);
|
||||
DISABLE_WARNING_UNREACHABLE_CODE
|
||||
|
||||
int
|
||||
main(int argc UNUSED, char *argv[] UNUSED)
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int i, tilenum;
|
||||
char filename[30];
|
||||
@@ -1395,6 +1395,8 @@ main(int argc UNUSED, char *argv[] UNUSED)
|
||||
free_tilerefs();
|
||||
exit(EXIT_SUCCESS);
|
||||
/*NOTREACHED*/
|
||||
nhUse(argc);
|
||||
nhUse(argv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1491,7 +1493,7 @@ add_tileref(
|
||||
const char *prefix)
|
||||
{
|
||||
struct tiles_used temp = { 0 };
|
||||
static const char ellipsis[] UNUSED = "...";
|
||||
static const char ellipsis[] = "...";
|
||||
char buf[BUFSZ];
|
||||
|
||||
if (!tilelist[n]) {
|
||||
@@ -1519,6 +1521,7 @@ add_tileref(
|
||||
(strlen(temp.references) >= (sizeof temp.references - 7) - 1)
|
||||
? buf
|
||||
: "");
|
||||
nhUse(ellipsis);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user