TrungNguyen1909 / qemu-t8030

iPhone 11 emulated on QEMU
Other
1.99k stars 206 forks source link

GCC on Linux doesn't recognized `__unused` #28

Closed skyline75489 closed 2 years ago

skyline75489 commented 2 years ago

This causes compilation error with:

https://github.com/TrungNguyen1909/qemu-t8030/blob/7f5549a9acf4ebe23456b588ed969fd287200ba5/hw/watchdog/apple_wdt.c#L145


GCC version

gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
TrungNguyen1909 commented 2 years ago

Duplicate of #17 and #20

TrungNguyen1909 commented 2 years ago

Or should we do something about it? Linux often complains about unused variables though...

skyline75489 commented 2 years ago

I mean if you want to go that far, GCC supports similar functionality with __attribute__((__unused__))

this is a rough example

#ifdef __GNUC__
#  define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
#else
#  define UNUSED(x) UNUSED_ ## x
#endif
TrungNguyen1909 commented 2 years ago

Fixed in 6c9d2f9884c54fb418d73b4b9304160a42eaede2 and 4945950df1a9285181e6540d80e8f8a83f4e1917