简体   繁体   English

Clion 有 1 个以上的 C 文件

[英]Clion with more than 1 C file

So i have been using VSCode and back there I had only to make new file save as .C and when I pressed the "run" it automaticly created the "exe" file by themself.所以我一直在使用VSCode,然后我只需要将新文件另存为.C,当我按下“运行”时,它会自动创建“exe”文件。

This method is important to me because as I am on programming class, I have the ABCDEF ... exercise to run.这个方法对我很重要,因为当我在编程课上时,我有 ABCDEF ... 练习要运行。

I heard Clion was one of the best tools out there for C, and i have a student acc so decided to try.我听说 Clion 是最好的 C 工具之一,我有一个学生 acc 所以决定尝试一下。 But here when I create a new project it only lets me run the first file, tried to add a new source file but it fails.但是在这里,当我创建一个新项目时,它只让我运行第一个文件,尝试添加一个新的源文件但它失败了。

Is there any solution ?有什么解决办法吗? Thanks谢谢

这是在 VSC 上

CLion uses CMake as makefile generator. CLion 使用 CMake 作为 makefile 生成器。 I think this question is about CMake "language" and not about CLion.我认为这个问题是关于 CMake“语言”而不是关于 CLion。 With CMake you can create multiple executables but there is no automatic way to do it.使用 CMake,您可以创建多个可执行文件,但没有自动的方法来做到这一点。

You can't have more than one source file if you want it to run independently in the same project.如果您希望它在同一个项目中独立运行,则您不能拥有多个源文件。 As you may know there should be only one main function where the program initiates.正如您可能知道的那样,程序启动的地方应该只有一个主要功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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