FirebaseExtended / firebase-arduino

Arduino samples for Firebase.
Apache License 2.0
945 stars 494 forks source link

Drop arduino String class at the FirebaseArduino layer. #117

Closed ed7coyne closed 8 years ago

ed7coyne commented 8 years ago

We should translate from String to std::string at the FirebaseArduino layer and use std::string on all internal classes. This will make the library portable and will make testing easier.

Once this is done we can stop patching ArduinoJson releases to address our conflicting String overrides as well.

proppy commented 8 years ago

We should also make sure if possible that the conversion doesn't add too many extra copies.

Maybe we could have overrides that also accept char* + size.

ed7coyne commented 8 years ago

I don't think this will be feasible. Unfortunately I did not find out until pretty late that Arduino IDE cannot link std::string at all :(

I will keep looking for a way to make it happen but you just get a bunch of: undefined reference tostd::basic_string<char, std::char_traits, std::allocator >::~basic_string()'`

I have a branch pretty much ready to go otherwise as this is a linking error so all compilation issues are fixed: https://github.com/googlesamples/firebase-arduino/compare/master...ed7coyne:remove-arduino-string

proppy commented 8 years ago

So you should only need to force the instantiation of the std::string template to make that work:

template class std::basic_string<char>;

See https://github.com/esp8266/Arduino/issues/1136#issuecomment-162331360

ed7coyne commented 8 years ago

hmm good find. Addressed most of them. Now I am just left with: sketch/FirebaseDemo_ESP8266.ino.cpp.o: In functionloop': /usr/local/google/home/edcoyne/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/xtensa-lx106-elf/include/c++/4.8.2/bits/basic_string.tcc:732: undefined reference to std::__throw_out_of_range(char const*)' sketch/FirebaseDemo_ESP8266.ino.cpp.o: In functionstd::basic_string<char, std::char_traits, std::allocator >::_M_check(unsigned int, char const) const': /usr/local/google/home/edcoyne/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/xtensa-lx106-elf/include/c++/4.8.2/bits/basic_string.tcc:732: undefined reference to `std::__throw_out_of_range(char const)' collect2: error: ld returned 1 exit status`

ed7coyne commented 8 years ago

If they will accept https://github.com/esp8266/Arduino/pull/2062 it will fix it. We may need a temporary fix on our side until then.

dirkvranckaert commented 8 years ago

my code cannot be compiled for Arduino since adding this library: #include <FirebaseArduino.h> Error: `/Users/dirkvranckaert/Documents/Arduino/libraries/firebase-arduino-master/src/FirebaseArduino.h:20:18: fatal error: string: No such file or directory

include `

I guess that's what this issue is all about. How can I get passed this issue and still compile? Why is this an issue with my arduino uno?

proppy commented 8 years ago

@dirkvranckaert this library currently only works with esp8266 boards (arduino compatible, builtin WiFi). I'd be tricky to get it to work with Uno unless you get some kind of Wifi or Ethernet shield.

dirkvranckaert commented 8 years ago

Allright, I have one around (a Wemos D1), just gave it a try and indeed compilation succeeds! Will try one of the examples! Thanks a lot!

proppy commented 8 years ago

Fixed with #169

varun9597 commented 6 years ago

my code cannot be compiled for Arduino since adding this library: #include <FirebaseArduino.h> Error: /Users/dirkvranckaert/Documents/Arduino/libraries/firebase-arduino-master/src/FirebaseArduino.h:20:18: fatal error: string: No such file or directory #include <string>

I guess that's what this issue is all about. How can I get passed this issue and still compile? Why is this an issue with my arduino uno?

Even I am facing the same issue. I don't have a builtIn WiFi Board. I am using Arduino Mega 2560 with ESP8266. And using SoftwareSerial to communicate with the ESP8266. Can you help me out please?