Disable warnings in unused header code?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



   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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux