This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Disable warnings in unused header code?


   Is there a way to disable warnings for code that is not actually
used? Suppose I have this class:

 template<typename T> struct Foo
 {
     inline Foo(T x) : x(x) {}
     T x;
 };

   I would like to provide functions such as this in a public header:

 static inline bool operator >=(Foo<unsigned> const &a, Foo<int> const &b)
 {
     return a.x >= b.x;
 }

   The user can then have "Foo<unsigned> a, b" and test "a >= b".
But they can also test "a >= 10" thanks to the implicit conversion
constructor.

   My problem is that g++ emits a signed/unsigned mismatched comparison
warning with -W even when the function is not used. I do want the
warning to trigger when the function is actually used, so that the user
can knowingly decide to use, and maybe disable the warning.

   I have tried using __attribute__((always_inline)), as well as several
combinations of optimisation flags, with no luck.

   Do I have other options?

Regards,
-- 
Sam.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]