4 ms·
Marlin project seems to abuse the hell out #ifdef and the project seems to work well. I don't know what I would use to replace them in an embedded space, they a
by Dork1234 5y ago
Marlin project seems to abuse the hell out #ifdef and the project seems to work well. I don't know what I would use to replace them in an embedded space, they are counting every byte that gets created in binary, and used in memory.
I do agree anything larger than a project like Marlin the process turns into a mess, with little benefit.
Here is an example configuration file, it isn't that bad.
https://github.com/MarlinFirmware/Configurations/blob/import-2.0.x/config/examples/Creality/Ender-3/BigTreeTech%20SKR%20Mini%20E3%201.2/Configuration.h https://github.com/MarlinFirmware/Configurations/blob/import...
- gravypod 5y agoYou can do something similar to what golang does. You can define an interface and then have a `thing_x86.c` and a `thing_arm64.c` etc. If you abstract the problem this way you are very explicit about what is being linked into the binary while not having the complex state management issues of preprocessor magic.
- rurban 5y agoEmbedded uses such HAL's extensively. There is no such nested ifdef mess mid-level devs love to create. Linux KConfig system is also properly designed, leading to properly seperated features. Never mix compile-time logic with runtime logic, you get lost. No need for a study to verify this. #ifdef is not considered harmful, only stupid usage of it.