質問

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