Is there any functional difference between marking a virtual
method's unused parameter arguments with GCC's __attribute__((unused))
and casting the argument to (void)
?
class Other {
virtual int sum(int a, int b, int c);
};
class Example : Other {
virtual int sum(int a, int b, int c __attribute__((unused))) override {
return a + b;
}
};
class Example2 : Other {
virtual int sum(int a, int b, int c) override {
(void)c;
return a + b;
}
};
Both do the job of silencing unused argument warnings and neither of them warn, if the variable is used later. Though the GCC __attribute__
is longer.