Microsoft Visual C++,无需工程文件即可编译小源代码

2022-01-04 00:00:00 file compilation c++ dev-c++

好吧,我一直在使用 Dev-C++ 来学习语言 [c++],但有些东西无法正常工作,例如全局变量和局部变量.然后我决定下载 Microsoft Visual C++ 来看看它的比较,它绝对很棒;尤其是它的美学.不过,让我感到困扰的一件事是,由于我需要制作大量小源文件来测试我学到的东西,因此我必须每次都制作一个大型项目文件,这会占用 ~18mb 的空间.我试图只制作一个源 C++ 文件,但它永远不会工作,因为编译和运行按钮在没有项目文件的情况下不会突出显示,并且按 f5 也不会产生任何结果.但是使用 Dev-C++,我可以直接打开它,控制+n,然后快速编写程序,编译它就会显示出来,不需要项目文件.那么有没有一种方法可以在 Microsoft Visual C++ 中编译单个源文件,而无需制作项目文件来包含它?

Well, I've been using Dev-C++ for a while for learning the language [c++], and some stuff wouldn't work properly, like global and local variables. Then I decided to download Microsoft Visual C++ to see how it compared, and it was absolutely great; especially with its aesthetics. One thing that has bothered me, though, is that since I need to make lots of small source files to test out things I've learned, I have to make a large project file each and every time, which take up ~18mb of space. I have tried to just make a source C++ file, but it never works since the compile and run buttons don't highlight without a project file, and pressing f5 yields no result as well. But with Dev-C++, I could just open it up, control+n, and write the program quickly, compile and it'd show up, no need for a project file. So is there a way to to compile single source files in Microsoft Visual C++ without needing to make a project file to include it in?

推荐答案

我通常为临时工作制作一个项目,然后重复使用它.如果您真的非常需要保留学习文件,那么只需创建一个项目,添加新的源文件,并从构建中排除所有旧文件.无需为每个临时或学习项目都创建一个新项目.

I typically make one project for temporary work and just re-use it. If you have a really desperate need to keep around your learning files, then just make one project, add new source files, and exclude all the old ones from the build. There's no need to make a new project for every temporary or learning project.

相关文章