This is the mail archive of the gcc@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]

Turning off C++ casting??


Is there a way to disable C++ casting?  That is, during
development/debugging I like using C++ casts like dynamic_cast to ensure
my parameters are correct.  However, for a release build where I'm
confident 'all down-casting' is safe, I would like the casting to be
turn off - that is, something similar to 'C' type casting:

// Debug build
void func(BaseObject& obj) {
  ExtendedObject& obj = dynamic_cast<ExtendObject&>(obj);   
//...
}

// Release build
void func(BaseObject& obj) {  
  ExtendedObject& obj = *((ExtendObject*)((void*)arg)); // release build
//...
}

Correct me if I'm wrong, but I believe the release build is faster.




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