title: Why Are Vtables Not Being Implemented Correctly On Embedded Platform?
body: <p>I am developing code for an embedded system (specifically, the PSoC 5, using PSoC Creator), and writing in C++.</p>
  
  <p>While I've overcome most hurdles with using C++ , first off compiling in C++ using the compiler flag <code>-x c++</code>, defining the new and delete operators, making sure exceptions aren't thrown with the compiler flag <code>-fno-exception</code>, I've come to a brick wall when it comes to using virtual functions.</p>
  
  <p>If I try and declare a virtual function, the compiler gives me the error <code>undefined reference to "vtable for __cxxabiv1::__class_type_info"</code>. The only way to get around this is to use the compiler flag <code>-fno-rtti</code>, which prevents the error and makes it compile successfully. However, if I do that, the embedded program crashes when trying to run the overloaded virtual function, and I'm thinking this is because the vtable does not exist.</p>
  
  <p>I don't see why you shouldn't be able to implement vtables on an embedded platform, since all it is a extra space in memory before or after member objects (depending on the exact compiler).</p>
  
  <p>The reason I am trying to use virtual functions is because I am wanting to use FreeRTOS with C++, and other people have implemented this by using virtual functions (see <a href="http://www.freertos.org/FreeRTOS_Support_Forum_Archive/July_2010/freertos_Is_it_possible_create_freertos_task_in_c_3778071.html" rel="noreferrer">http://www.freertos.org/FreeRTOS_Support_Forum_Archive/July_2010/freertos_Is_it_possible_create_freertos_task_in_c_3778071.html</a> for the discussion, and <a href="https://github.com/yuriykulikov/Event-driven_Framework_for_Embedded_Systems" rel="noreferrer">https://github.com/yuriykulikov/Event-driven_Framework_for_Embedded_Systems</a> for a well written embedded C++ FreeRTOS framework)</p>