문제

I've got a C++ project in XCode that builds a static library. I'd like to add a main method to the project to allow me to test some of the code in the library.

In an attempt to do this, I first duplicated the project's target, and I then added a main method to this second target (as per this answer). When I build and run this new target, however, my main method doesn't execute.

Does anyone have any idea what I'm doing wrong?

도움이 되었습니까?

해결책

The typical way to test a library is that you write a separate piece of code that exercises the libary, and compares the result with expected results.

In this case, the main will go into the test program, not the library. Having a main in the library is not the right thing, and will lead to very curious problems for the user of the library if the user forgets to supply a main...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top