4 ms·
Can possibly be done with a custom section, though not sure that is better and might require fancy compiler flags.
by cozzyd 5y ago
Can possibly be done with a custom section, though not sure that is better and might require fancy compiler flags.
- cozzyd 5y agoIndeed, I just made a POC with compiler sections: https://github.com/cozzyd/examc https://github.com/cozzyd/examc This implementation only works with gcc though probably (it uses the automatic __start_SECTION and __stop_SECTION that gcc generates but clang doesn't seem to... there are likely hacks to make this work anyway though). In principle, this approach allows interspersing your tests throughout a shared library instead of all in one file (though in that case you wouldn't want the testing function to be called main and you would need a separate driver program for test).