Solved

MSVC: mixing RTTI and non-RTTI code

Posted on 2001-06-05
5
375 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

775 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