My expectation & question is: I thought creating a library is easy but it’s hard and confusing but I’m still working on this and I want to learn how you guys made some. My question is how can I make this work? what are things that I need to put in my code. my knowledge in C/C++ is not really deep I only know the basics. Any tips would be greatly appreciated.
/data/fwbuild-volumes/2.18.0/apps/zip-iot-virus-index-nodemcu/esp8266/build_contexts/build_ctx_003116900/deps/mhz19/src/mgos_mhz19.cpp:4:37: error: 'serial' has not been declared
4 | void mgos_mhz19_begin(MHZ19 *mhz19, serial) {
| ^~~~~~
/data/fwbuild-volumes/2.18.0/apps/zip-iot-virus-index-nodemcu/esp8266/build_contexts/build_ctx_003116900/deps/mhz19/src/mgos_mhz19.cpp: In function 'void mgos_mhz19_begin(MHZ19*, int)':
/data/fwbuild-volumes/2.18.0/apps/zip-iot-virus-index-nodemcu/esp8266/build_contexts/build_ctx_003116900/deps/mhz19/src/mgos_mhz19.cpp:5:34: error: return-statement with a value, in function returning 'void' [-fpermissive]
5 | if (mhz19 == nullptr) return 0;
| ^
/data/fwbuild-volumes/2.18.0/apps/zip-iot-virus-index-nodemcu/esp8266/build_contexts/build_ctx_003116900/deps/mhz19/src/mgos_mhz19.cpp:6:25: error: 'serial' was not declared in this scope
6 | return mhz19->begin(serial)
| ^~~~~~
/data/fwbuild-volumes/2.18.0/apps/zip-iot-virus-index-nodemcu/esp8266/build_contexts/build_ctx_003116900/deps/mhz19/src/mgos_mhz19.cpp:6:31: error: return-statement with a value, in function returning 'void' [-fpermissive]
6 | return mhz19->begin(serial)
| ^
/data/fwbuild-volumes/2.18.0/apps/zip-iot-virus-index-nodemcu/esp8266/build_contexts/build_ctx_003116900/deps/mhz19/src/mgos_mhz19.cpp:6:32: error: expected ';' before '}' token
6 | return mhz19->begin(serial)
| ^
| ;
7 | }
| ~
In file included from /data/fwbuild-volumes/2.18.0/apps/zip-iot-virus-index-nodemcu/esp8266/build_contexts/build_ctx_003116900/deps/mhz19/src/mgos_mhz19.cpp:1:
/data/fwbuild-volumes/2.18.0/apps/zip-iot-virus-index-nodemcu/esp8266/build_contexts/build_ctx_003116900/deps/mhz19/src/mgos_mhz19.cpp: In function 'void mgos_mhz19_autoCalibration(MHZ19*, bool)':
/data/fwbuild-volumes/2.18.0/apps/zip-iot-virus-index-nodemcu/esp8266/build_contexts/build_ctx_003116900/deps/mhz19/include/mgos_mhz19.h:12:30: error: return-statement with a value, in function returning 'void' [-fpermissive]
12 | #define MGOS_MHZ19_RES_FAIL -10000
| ^~~~~
/data/fwbuild-volumes/2.18.0/apps/zip-iot-virus-index-nodemcu/esp8266/build_contexts/build_ctx_003116900/deps/mhz19/src/mgos_mhz19.cpp:19:33: note: in expansion of macro 'MGOS_MHZ19_RES_FAIL'
19 | if(mhz19 == nullptr) return MGOS_MHZ19_RES_FAIL;
| ^~~~~~~~~~~~~~~~~~~
/data/fwbuild-volumes/2.18.0/apps/zip-iot-virus-index-nodemcu/esp8266/build_contexts/build_ctx_003116900/deps/modules/mongoose-os/platforms/esp8266/Makefile.build:383: recipe for target '/data/fwbuild-volumes/2.18.0/apps/zip-iot-virus-index-nodemcu/esp8266/build_contexts/build_ctx_003116900/build/objs/mgos_mhz19.cpp.o' failed
make: *** [/data/fwbuild-volumes/2.18.0/apps/zip-iot-virus-index-nodemcu/esp8266/build_contexts/build_ctx_003116900/build/objs/mgos_mhz19.cpp.o] Error 1
make: *** Waiting for unfinished jobs....
make: Leaving directory '/app'
Error: exit status 2
I’ve edited your posts to be more readable and removed the irrelevant parts. Please use triple backticks to enclose your code/log.
As I said in a previous post, the errors are basic C/C++ programming errors.
E.g:
/data/fwbuild-volumes/2.18.0/apps/zip-iot-virus-index-nodemcu/esp8266/build_contexts/build_ctx_003116900/deps/mhz19/src/mgos_mhz19.cpp: In function 'void mgos_mhz19_begin(MHZ19*, int)':
/data/fwbuild-volumes/2.18.0/apps/zip-iot-virus-index-nodemcu/esp8266/build_contexts/build_ctx_003116900/deps/mhz19/src/mgos_mhz19.cpp:5:34: error: return-statement with a value, in function returning 'void' [-fpermissive]
5 | if (mhz19 == nullptr) return 0;
| ^
You return 0; in a function which is declared to have no return value. The compiler gives you the hint.
This has nothing to do with Mongoose OS, but with C/C++.