简体   繁体   中英

Change the startup file to be executed in visual studio 2010

In Visual Studio 2010 I created a test C++ project, with precompiled headers. So, Test1.cpp got created. When ever I hit run the code present in this file gets executed by default.

Suppose I manually add test2.cpp in the existing project. Then where should I change the setting in such a manner that after clicking run it executes the code present in test2.cpp by default.

Any help is appreciable!!!

After it's all compiled, the final binary doesn't know which file the code came from. (It's in the debug information, but that isn't used to run the code.) Instead, it runs whichever block of code has the correctly named entry point, in this case

int main(int argc, char* argv[])

(or probably _tmain for Unicode / not).

Do you have a main function in both files? That would cause linker errors. I suggest you just rename one out of the way, eg rename the one you don't want to run to main_test1 and the one you do to main .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM