googletest
googletest copied to clipboard
Add extern "C" to main entry point
since the bare metal or RTOS environment need demangled name
It is my understanding that
main()is special and never mangled. Can you elaborate on what is going on here?
Since all source codes are built into one image in bare metal or RTOS environment, we can't have main entry point more than once. To fix this limitation, one approach is:
- Add -Dmain=xxx_main when compile source files which contain main entry point
- Create a table contain all possible entry point like this:
{"gtest", gtest_main, ...},
{"gmock", gmock_main, ...},
A special shell will lookup this table to find and launch the entry point.
extern "C" mark can fix the issue in this case.
You should simply not link with great main and add your own main function see the examples
Yes, this is one of approach.