Skip to content

Commit 57c16bd

Browse files
committed
toolchain: Replace __attribute__((__unused__)) with __UNUSED
Abstracting this allows for the possibility of other compilers to have their own implementation of marking a variable as potentially unused without using the __attribute__ keyword (which is not supported on all compilers). Signed-off-by: Peter Mitsis <peter.mitsis@gmail.com>
1 parent 13c86d9 commit 57c16bd

File tree

13 files changed

+23
-16
lines changed

13 files changed

+23
-16
lines changed

code/ai/aiturret.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@ void turret_ai_update_aim(ai_info *aip, object *En_Objp, ship_subsys *ss)
13771377
*/
13781378
int aifft_rotate_turret(ship *shipp, int parent_objnum, ship_subsys *ss, object *objp, object *lep, vec3d *predicted_enemy_pos, vec3d *gvec)
13791379
{
1380-
int ret_val __attribute__((__unused__)) = 0; // to be used in future, see comment @ end of function
1380+
int ret_val __UNUSED = 0; // to be used in future, see comment @ end of function
13811381

13821382
if (ss->turret_enemy_objnum != -1) {
13831383
model_subsystem *tp = ss->system_info;

code/freespace2/freespace.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ void game_loading_callback_close()
12651265
// Make sure bar shows all the way over.
12661266
game_loading_callback(COUNT_ESTIMATE);
12671267

1268-
int real_count __attribute__((__unused__)) = game_busy_callback( NULL );
1268+
int real_count __UNUSED = game_busy_callback( NULL );
12691269
Mouse_hidden = 0;
12701270

12711271
Game_loading_callback_inited = 0;
@@ -1429,7 +1429,7 @@ int game_start_mission()
14291429
{
14301430
mprintf(( "=================== STARTING LEVEL LOAD ==================\n" ));
14311431

1432-
int s1 __attribute__((__unused__)) = timer_get_milliseconds();
1432+
int s1 __UNUSED = timer_get_milliseconds();
14331433

14341434
// clear post processing settings
14351435
gr_post_process_set_defaults();
@@ -1486,7 +1486,7 @@ int game_start_mission()
14861486

14871487
bm_print_bitmaps();
14881488

1489-
int e1 __attribute__((__unused__)) = timer_get_milliseconds();
1489+
int e1 __UNUSED = timer_get_milliseconds();
14901490

14911491
mprintf(("Level load took %f seconds.\n", (e1 - s1) / 1000.0f ));
14921492

@@ -1745,7 +1745,7 @@ char full_path[1024];
17451745
*/
17461746
void game_init()
17471747
{
1748-
int s1 __attribute__((__unused__)), e1 __attribute__((__unused__));
1748+
int s1 __UNUSED, e1 __UNUSED;
17491749
const char *ptr;
17501750
char whee[MAX_PATH_LEN];
17511751

code/fs2netd/fs2netd_client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ static void fs2netd_handle_messages()
737737

738738
case PCKT_SLIST_REPLY: {
739739
int numServers = 0;
740-
int svr_flags __attribute__((__unused__)); // gcc [-Wunused-but-set-variable] doesn't like MACROs
740+
int svr_flags __UNUSED; // gcc [-Wunused-but-set-variable] doesn't like MACROs
741741
ushort svr_port;
742742
char svr_ip[16];
743743
active_game ag;

code/fs2netd/tcp_client.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ int FS2NetD_GetPlayerData(const char *player_name, player *pl, bool can_create,
218218
uint rc_total = 0;
219219
ubyte reply_type = 0;
220220
int si_index = 0;
221-
ushort bogus __attribute__((unused));
221+
ushort bogus __UNUSED;
222222
ushort num_type_kills = 0, num_medals = 0;
223223
char ship_name[NAME_LENGTH];
224224
int idx;
@@ -489,8 +489,8 @@ int FS2NetD_Login(const char *username, const char *password, bool do_send)
489489
int rc;
490490
uint rc_total = 0;
491491
ubyte login_status = 0;
492-
int sid __attribute__((unused));
493-
short pilots __attribute__((unused));
492+
int sid __UNUSED;
493+
short pilots __UNUSED;
494494

495495
do {
496496
rc = FS2NetD_GetData(buffer+rc_total, sizeof(buffer)-rc_total);

code/globalincs/toolchain/clang.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#define SCP_FORMAT_STRING
2121
#define SCP_FORMAT_STRING_ARGS(x,y) __attribute__((format(printf, x, y)))
2222

23+
#define __UNUSED __attribute__((__unused__))
24+
2325
#ifdef NO_RESTRICT_USE
2426
# define RESTRICT
2527
#else

code/globalincs/toolchain/gcc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#define SCP_FORMAT_STRING
2121
#define SCP_FORMAT_STRING_ARGS(x,y) __attribute__((format(printf, x, y)))
2222

23+
#define __UNUSED __attribute__((__unused__))
24+
2325
#ifdef NO_RESTRICT_USE
2426
# define RESTRICT
2527
#else

code/globalincs/toolchain/mingw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#define SCP_FORMAT_STRING
2121
#define SCP_FORMAT_STRING_ARGS(x,y) __attribute__((format(printf, x, y)))
2222

23+
#define __UNUSED __attribute__((__unused__))
24+
2325
#ifdef NO_RESTRICT_USE
2426
# define RESTRICT
2527
#else

code/globalincs/toolchain/msvc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define SCP_FORMAT_STRING_ARGS(x,y)
2424

2525
#define __attribute__(x)
26+
#define __UNUSED
2627

2728
#ifdef NO_RESTRICT_USE
2829
# define RESTRICT

code/pilotfile/csg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ void pilotfile::csg_read_settings()
11111111

11121112
if (csg_ver < 3) {
11131113
// detail
1114-
int dummy __attribute__((__unused__)) = cfread_int(cfp);
1114+
int dummy __UNUSED = cfread_int(cfp);
11151115
dummy = cfread_int(cfp);
11161116
dummy = cfread_int(cfp);
11171117
dummy = cfread_int(cfp);
@@ -1152,7 +1152,7 @@ void pilotfile::csg_write_settings()
11521152
void pilotfile::csg_read_controls()
11531153
{
11541154
int idx, list_size;
1155-
short id1, id2, id3 __attribute__((__unused__));
1155+
short id1, id2, id3 __UNUSED;
11561156

11571157
list_size = (int)cfread_ushort(cfp);
11581158

code/pilotfile/plr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ void pilotfile::plr_write_stats_multi()
600600
void pilotfile::plr_read_controls()
601601
{
602602
int idx, list_size, list_axis;
603-
short id1, id2, id3 __attribute__((__unused__));
603+
short id1, id2, id3 __UNUSED;
604604
int axi, inv;
605605

606606
list_size = (int)cfread_ushort(cfp);

0 commit comments

Comments
 (0)