ppedro74 / Arduino-SerialCommands

BSD 3-Clause "New" or "Revised" License
87 stars 29 forks source link

Example does not compile #13

Open calcut opened 3 years ago

calcut commented 3 years ago

In arduino IDE, with ESP32-S2, I tried compiling the example "Multiple Serial Ports" from the readme I get the following errors and warnings

In file included from /Users/calum/Documents/Arduino/sketch_sep10b/sketch_sep10b.ino:1:
/Users/calum/Documents/Arduino/libraries/SerialCommands/src/SerialCommands.h:42:80: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  SerialCommands(Stream* serial, char* buffer, int16_t buffer_len, char* term = "\r\n", char* delim = " ") :
                                                                                ^~~~~~
/Users/calum/Documents/Arduino/libraries/SerialCommands/src/SerialCommands.h:42:102: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
  SerialCommands(Stream* serial, char* buffer, int16_t buffer_len, char* term = "\r\n", char* delim = " ") :
                                                                                                      ^~~
/Users/calum/Documents/Arduino/sketch_sep10b/sketch_sep10b.ino:4:104: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 SerialCommands serial_commands_0_(&Serial, serial_commands_0_buffer_, sizeof(serial_commands_0_buffer_));
                                                                                                        ^
/Users/calum/Documents/Arduino/sketch_sep10b/sketch_sep10b.ino:4:104: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
/Users/calum/Documents/Arduino/sketch_sep10b/sketch_sep10b.ino:7:105: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 SerialCommands serial_commands_1_(&Serial1, serial_commands_1_buffer_, sizeof(serial_commands_1_buffer_));
                                                                                                         ^
/Users/calum/Documents/Arduino/sketch_sep10b/sketch_sep10b.ino:7:105: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
/Users/calum/Documents/Arduino/sketch_sep10b/sketch_sep10b.ino: In function 'void setup()':
sketch_sep10b:28:40: error: invalid conversion from 'void (*)(SerialCommands*)' to 'void (*)(SerialCommands*, const char*)' [-fpermissive]
   serial_commands_0_.SetDefaultHandler(&cmd_hello);
                                        ^~~~~~~~~~
In file included from /Users/calum/Documents/Arduino/sketch_sep10b/sketch_sep10b.ino:1:
/Users/calum/Documents/Arduino/libraries/SerialCommands/src/SerialCommands.h:92:31: note:   initializing argument 1 of 'void SerialCommands::SetDefaultHandler(void (*)(SerialCommands*, const char*))'
  void SetDefaultHandler(void(*function)(SerialCommands*, const char*));
                         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sketch_sep10b:32:40: error: invalid conversion from 'void (*)(SerialCommands*)' to 'void (*)(SerialCommands*, const char*)' [-fpermissive]
   serial_commands_1_.SetDefaultHandler(&cmd_hello);
                                        ^~~~~~~~~~
In file included from /Users/calum/Documents/Arduino/sketch_sep10b/sketch_sep10b.ino:1:
/Users/calum/Documents/Arduino/libraries/SerialCommands/src/SerialCommands.h:92:31: note:   initializing argument 1 of 'void SerialCommands::SetDefaultHandler(void (*)(SerialCommands*, const char*))'
  void SetDefaultHandler(void(*function)(SerialCommands*, const char*));
                         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
exit status 1
invalid conversion from 'void (*)(SerialCommands*)' to 'void (*)(SerialCommands*, const char*)' [-fpermissive]
calcut commented 3 years ago

... actually I can see the examples in the examples folder compile without warnings in the master version of this. Will press on with those.