Closed ustisha closed 3 years ago
Sorry about empty comment. General problem in my build configuration with CLion + cmake, Object linker does not remove Serial library from binary file when used in code.
I appreciate you have added some context describing your problem but unfortunately I still don't understand the problem you are having. Could you provide any additional detail or perhaps explain it again a different way? What platform are you using the library on (Arduino, ESP8266, ESP32, etc)? How does "Object linker does not remove Serial library from binary file when used in code" affect the operation of the library? What is the problem this produces?
To omit those #define
blocks, you can do this:
#ifdef BH1750_DEBUG
#define LOG(fmt, ...) (Serial.printf("%09llu: " fmt "\r\n", GetTimestamp(), ##__VA_ARGS__)); Serial.flush();
#else
#define LOG(fmt, ...)
#endif
//Serial.println(F("[BH1750] ERROR: Invalid mode"));
LOG("[BH1750] ERROR: Invalid mode");
currently I didn't found a way to get the F() call properly through this.
I need reduce size of the firmware to fit into 32KB Arduino. For this, linker flags "-ffunction-sections -Wl, - gc-sections" are used. Before compiling release firmware, I turn off "debug" mode by macro that removes calls to Serial.begin (), Serial.write(), etc, inside my project, but call Serial.println() exists in your library, which prevents the optimizer deleting the library Serial. Thats help me to save few KBs.
These errors hardly ever occur so should not be clogging up a terminal session showing output - if that was your concern. Are you seeing these error condition lines being reported much?
Those serial output lines were intentionally not wrapped with the debug flag so they can always be seen by a user as they generally represent serious errors - that need attention. If you hide those error condition reporting lines then users will not receive any feedback when errors occur - which I think that would be really frustrating for a user. If errors are occurring I think a user would want to know.
You did not post any context in your merge request. What was your reason for proposing this change?