gcc - base class 'foo' has a non-virtual destructor
-
hallo,
ich suche eine möglichkeit; am besten ohne
#pragmaoder ähnliche compiler-spezifische direktiven; die warning zu deaktivieren
(deshalb im c++-forum und nicht im compiler-forum)struct foo { }; struct bar : foo { }; int main() {}nutzen tu ich das ganze für einen wrapper; ähnlich zu boost::strong_typedef (nur eben kein makro):
template<class TYPE_DEF, class NUM_TYPE> struct wrapper { wrapper(NUM_TYPE value_) : value(value_) {} operator NUM_TYPE() const {return value;} operator bool() const {return value != 0;} template<class T> friend bool operator==(TYPE_DEF lhs, T rhs) {return lhs.value == NUM_TYPE(rhs);} template<class T> friend bool operator!=(TYPE_DEF lhs, T rhs) {return lhs.value != NUM_TYPE(rhs);} template<class T> friend bool operator< (TYPE_DEF lhs, T rhs) {return lhs.value < NUM_TYPE(rhs);} template<class T> friend bool operator<=(TYPE_DEF lhs, T rhs) {return lhs.value <= NUM_TYPE(rhs);} template<class T> friend bool operator>=(TYPE_DEF lhs, T rhs) {return lhs.value >= NUM_TYPE(rhs);} template<class T> friend bool operator> (TYPE_DEF lhs, T rhs) {return lhs.value > NUM_TYPE(rhs);} template<class T> friend NUM_TYPE operator%(TYPE_DEF lhs, T rhs) {return lhs.value % NUM_TYPE(rhs);} template<class S> friend S& operator<<(S& s, TYPE_DEF rhs) {return s << rhs.value;} private: NUM_TYPE value; }; struct special_int : wrapper<special_int, int> { special_int(int value_ = 0) : wrapper<special_int, int>(value_) {} /*...funktionen - deshalb ist auch BOOST_STRONG_TYPEDEF(int, special_int) keine alternative...*/ };nur wegen einer warning foo(wrapper) einen virtuellen dtor zu verpassen, ist keine option.
danke im voraus
-
template<class, class> struct wrapper { /* ... */ protected: ~wrapper() {}; };Stellt ihn das ruhig?
-
unskilled schrieb:
struct bar : fooKeine Ahnung, ob das hilft, aber an der Stelle zuckte mein linkes Auge.
-
Xin schrieb:
<trolling>
pumuckl schrieb:
template<class, class> struct wrapper { /* ... */ protected: ~wrapper() {}; };Stellt ihn das ruhig?
ne, bringt nichts.
bb
-
Das ist eine -Weffc++ Warnung.
Das sind keine Warnung im Sinne von "Achtung da passiert was gefährliches" sondern einfach eine Verletzung der Guidelines aus Effective C++.Das ist zwar nett zum mal drüber schauen über den Code, aber diese Warnungen sind zu "dumm" um wirklich etwas zu bringen. Einfach nicht einschalten und schon ist das Problem gelöst.
Die Doku sagt btw folgendes:
When selecting this option, be aware that the standard library headers do not obey all of these guidelines; use `grep -v' to filter out those warnings.
PS:
sprich: selbst 100% korrekter Code kann diese Warnungen generieren und man kann nichts dagegen tun.
-
Shade Of Mine schrieb:
Die Doku sagt btw folgendes:
When selecting this option, be aware that the standard library headers do not obey all of these guidelines; use `grep -v' to filter out those warnings.
PS:
sprich: selbst 100% korrekter Code kann diese Warnungen generieren und man kann nichts dagegen tun.überzeugt - danke^^