Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By Alex_S
#7575 jcmvbkbc, igrr,
Thanks a lot for your recomendations!
Great work!!!
User avatar
By Pawel Ka
#11943 Hi (first post ;-))

I'm trying to use g++ (compiler related with this thread) and virtual function, but code crashes on ESP while invoking virtual function.

Sample code:
Code: Select allclass A {
   void run(){
   virtual void foo() = 0;

class B : public A{
   void foo(){
      Serial.println("TEST"); //what ever debug information you need

B test;
test.foo(); //works, I see TEST in termial
test.run(); //crashes with Exception(28)

Error message:
Code: Select allFatal exception (28):

Does anyone have idea what can be wrong with compiler? The same code with g++ x86 compiler works properly.
User avatar
By Pawel Ka
#11984 I found that I had configured g++ parameter "-fno-rtti", so no support for virtual functions (it's main problem), but after removing parameter I have a problem with missing reference to vtable.

Does anyone know, how to use virtual functions (vtable) with esp8266? What kind of parameters should be added to compiler?
User avatar
By joostn
#11992 -f-no-rtti is fine, I'm using that as well.
Are you running the global constructors manually? This is required because the startup code doesn't do it. See page 1 of this same thread. You can see if this is the case by moving your test code inside a function (void test()) and see if it works, because then it's not a global object anymore.

If you don't, your class B (including virtual function table) will not be initialized.