Solved

MSVC: mixing RTTI and non-RTTI code

Posted on 2001-06-05
5
368 Views
Last Modified: 2012-05-04
Hi all,
My question is whether it is safe to mix RTTI-enabled and RTTI-disabled. I am asking, because I guess MSVC adds an
extra pointer to vtable structure, so probably it should not be safe, as compiler will not be able to allocate/deallocate memory properly.

If the answer is "NO", then my other questions is: suppose I have third-party library, how do I tell whether it is RTTI-enabled or not.
Finally, if I have two third-party libraries, one is RTTI-enabled and second RTTI-disabled, how can I make them work together in my program.

Thanks
0
Comment
Question by:proskig
  • 4
5 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 6155804
>> My question is whether it is safe to mix RTTI-enabled and RTTI-disabled.
probably not, but I don't know for sure.

>> adds an extra pointer to vtable structure,
many compilers use the first entry in vtable to store a pointer to a structure that has the RTTI info.   But VC has to be COM compatible too.  I don't know if COM woudl require the 1st entry to be a working entry.

This will take a little testing....
0
 
LVL 22

Expert Comment

by:nietod
ID: 6155849
VC uses the same vtable for both cases and the first entry is the pointer to the first virtual function.  There will be no incompatibility there.   its possible that it places the RTTI infor before the table.  I'll look into that.   But it seems like it might be safe as long as you don't actually use RTTI.
0
 
LVL 22

Accepted Solution

by:
nietod earned 200 total points
ID: 6155899
VC seems to be storing something before the start of the table.  its not the RTTI info itself and it is not a pointer to it, but it is definitely accessing the doubleword before the start of the table.    This suggests that it is probaly safe to mix RTTI and non-RTTI, if you really have to.
0
 
LVL 5

Author Comment

by:proskig
ID: 6156034
OK, thanks, it looks the same to me
0
 
LVL 22

Expert Comment

by:nietod
ID: 6156087
That was a guess though...
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now