[英]Eclipse CDT: multiple C++ files in single project
I'm on Mac OS Mojave(Version 10.14), using Eclipse Photon. 我在Mac OS Mojave(版本10.14)上使用Eclipse Photon。 I have a single C++ project(which won't show up in the C++ perspective, only the Java perspective), and I'd like multiple packages/folders for various things.
我有一个单独的C ++项目(它不会出现在C ++透视图中,只有Java透视图),而且我想要各种各样的包/文件夹。 For example:
例如:
- MyCPPProject - School - Lab01.cpp - Lab02.cpp - Personal - File01.cpp - File02.cpp
All of the C++ files will have main methods(which is why I can't run them if they're in the same project). 所有C ++文件都有主要方法(这就是为什么我不能运行它们,如果它们在同一个项目中)。 All of the files will be "simple," meaning that they will not do anything beyond competitive programming(so nothing beyond
cin
/ cout
or scanf
). 所有文件都是“简单的”,这意味着除了竞争性编程之外他们不会做任何事情(因此除了
cin
/ cout
或scanf
之外什么都没有)。
The Internet says I need a new project for every main method. 互联网说我需要一个针对每种主要方法的新项目。 Does anyone have any ideas so that I can keep my programs in 1 project?
有没有人有任何想法,以便我可以将我的程序保存在一个项目中?
Thanks in advance. 提前致谢。
The way Java works, you can have a different static void main(String[] args)
for every Java class. Java的工作方式,您可以为每个Java类使用不同的
static void main(String[] args)
。 Neither C nor C++ work like that: you're limited to exactly one "main()" per .exe. C和C ++都不是那样的:每个.exe只限于一个“main()”。
That, in turn, means that you must define a separate project in Eclipse for each separate .exe. 反过来,这意味着您必须在Eclipse中为每个单独的.exe定义一个单独的项目。 That's just the way it is :)
就是那样子 :)
Eclipse, however, allows you to "group" projects into "Working Sets": 但是,Eclipse允许您将项目“分组”为“工作集”:
What is a working set and how do I use it? 什么是工作集,我该如何使用它?
So if you wanted to, you could organize your projects into "School" and "Personal", filtering out one or the other as you wish. 因此,如果您愿意,可以将项目组织成“学校”和“个人”,根据需要过滤掉一个或另一个。
Finally, there are C/C++ "Online Fiddles" that allow you to easily run small, standalone .cpp files and that you might prefer over Eclipse, MSVS or CodeBlocks: 最后,还有C / C ++“在线小提琴”,它允许您轻松运行小型,独立的.cpp文件,并且您可能更喜欢Eclipse,MSVS或CodeBlocks:
'Hope that helps! '希望有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.