-->
Page 7 of 7

Re: C++

PostPosted: Sun Mar 15, 2015 12:46 pm
by Pawel Ka
Thx, it's work. I haven't run global constructors manually. That was my problem ;-)

Re: C++

PostPosted: Mon Mar 23, 2015 5:17 pm
by krimpsok
I noticed that os_delay_us is not working on the C++ compiler

Code: Select allDescription   Resource   Path   Location   Type
'ets_delay_us' was not declared in this scope   RemoteTransmitter.cpp   /Switcher/user   line 96   C/C++ Problem
'ets_delay_us' was not declared in this scope   RemoteTransmitter.cpp   /Switcher/user   line 155   C/C++ Problem
mingw32-make.exe: *** [build/user/RemoteTransmitter.o] Error 1   Switcher          C/C++ Problem
recipe for target 'build/user/RemoteTransmitter.o' failed   Makefile   /Switcher   line 322   C/C++ Problem


When compiling with the C compiler everything is fine.

Re: C++

PostPosted: Tue Mar 24, 2015 8:08 am
by Alex_S
Unfortunately not all the function prototypes are declared in SDKs headers. C allows to compile without such declarations, assuming int(int), but C++ requires prompt delcarations.
So just add the declarations of the used SDK functions and it will be compiled and linked correctly.
Note: don't forget 'extern "C"' for this declarations.

Re: C++

PostPosted: Tue Mar 24, 2015 3:03 pm
by krimpsok
I used extern "C" to declare my missing ets_delay_us(int us) but now I'm getting a weird error on multiple lines.

Code: Select allDescription   Resource   Path   Location   Type
mingw32-make.exe: *** [build/app.out] Error 1   Switcher          C/C++ Problem
more undefined references to `gpio_output_set(unsigned int, unsigned int, unsigned int, unsigned int)' follow   RemoteTransmitter.cpp   /Switcher/user   line 98   C/C++ Problem
recipe for target 'build/app.out' failed   Makefile   /Switcher   line 219   C/C++ Problem
undefined reference to `gpio_output_set(unsigned int, unsigned int, unsigned int, unsigned int)'   RemoteTransmitter.cpp   /Switcher/user   line 54   C/C++ Problem
undefined reference to `gpio_output_set(unsigned int, unsigned int, unsigned int, unsigned int)'   RemoteTransmitter.cpp   /Switcher/user   line 86   C/C++ Problem
undefined reference to `gpio_output_set(unsigned int, unsigned int, unsigned int, unsigned int)'   RemoteTransmitter.cpp   /Switcher/user   line 87   C/C++ Problem
undefined reference to `gpio_output_set(unsigned int, unsigned int, unsigned int, unsigned int)'   RemoteTransmitter.cpp   /Switcher/user   line 90   C/C++ Problem
undefined reference to `gpio_output_set(unsigned int, unsigned int, unsigned int, unsigned int)'   RemoteTransmitter.cpp   /Switcher/user   line 107   C/C++ Problem


The weird part about this error is that gpio_output_set IS defined in gpio.h which I include. I'll post a pastebin link to the code I've been working on so far. http://pastebin.com/xKmDRxRZ. It's an Arduino library which I'm converting for use with the ESP8266.

EDIT::
I fixed my problem by including the gpio.h via the extern "C" method.