Visual Studio 上的 C

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28605/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 12:20:53  来源:igfitidea点击:

C on Visual Studio

c++cidecompiler-construction

提问by Dinah

I'm trying to learn C. As a C# developer, my IDE is Visual Studio. I've heard this is a good environment for C/C++ development. However, it seems no matter what little thing I try to do, intuition fails me. Can someone give good resources for how to either:

我正在尝试学习 C。作为 C# 开发人员,我的 IDE 是 Visual Studio。我听说这是一个很好的 C/C++ 开发环境。然而,似乎无论我尝试做什么小事,直觉都让我失望。有人可以为如何提供良好的资源:

  • learn the ins and out of C in Visual Studio
  • recommend a better C IDE + compiler
  • 在 Visual Studio 中学习 C 的来龙去脉
  • 推荐一个更好的C IDE + 编译器


Edit:See also: https://stackoverflow.com/questions/951516/a-good-c-ide

编辑:另见:https: //stackoverflow.com/questions/951516/a-good-c-ide

采纳答案by sparkes

Answering the purely subject question "recommend me a better C IDE and compiler" I find Ming32w and Code::blocks (now with combined installer)very useful on windows but YMMV as you are obviously used to the MS IDE and are just struggling with C.

回答纯粹的主题问题“推荐我一个更好的 C IDE 和编译器”我发现Ming32w 和 Code::blocks(现在带有组合安装程序)在 Windows 上非常有用,但 YMMV 因为你显然已经习惯了 MS IDE 并且只是在与 C 斗争.

May I suggest you concentrate on console applications to get a feel for the language first before you attempt to tie it together with a windows UI which in my experience is the hardest bit of windows development.

我是否建议您先专注于控制台应用程序,以便在尝试将其与 Windows UI 结合在一起之前先感受一下该语言,这在我的经验中是 Windows 开发中最难的部分。

回答by MehranNZ

well you can use visual studio just fine take a look at here man http://www.daniweb.com/forums/thread16256.html

那么你可以使用visual studio就好了,看看这里的人 http://www.daniweb.com/forums/thread16256.html

Go to View Menu select Solution Explorer or CTRL+ ALT +L

转到查看菜单选择解决方案资源管理器或 CTRL+ALT+L

Then Select The project that your are developing and right click on that.

然后选择您正在开发的项目并右键单击该项目。

Then select the Properties from the submenu.

然后从子菜单中选择属性。

Then select the Configuration properties from the Tree structure. under that select C/C++ then select Advanced. Now in the right side pane change the property

然后从树结构中选择配置属性。在该选项下选择 C/C++,然后选择高级。现在在右侧窗格中更改属性

Compile As from Compile as C++ Code (/TP) to Compile as C Code (/TC)

编译为从编译为 C++ 代码 (/TP) 到编译为 C 代码 (/TC)

Finally change your file extensions to .c

最后将您的文件扩展名更改为 .c

Now you configured you Visual Studio to compile C programs

现在您已将 Visual Studio 配置为编译 C 程序

And you can use NetBeans too it could even be more user friendly than Visual Studio download it you wont regret i promise

而且您也可以使用 NetBeans 它甚至可能比 Visual Studio 下载更加用户友好,我保证您不会后悔

回答by Antonio Haley

The problem with learning C within Visual Studio is that you are compiling C using the Visual Studio C++ compiler. You might want to try learning C using the GNU GCCcompiler from within the Cygwinenvironment in Windows.

在 Visual Studio 中学习 C 的问题是您正在使用 Visual Studio C++ 编译器编译 C。您可能想尝试在 Windows的Cygwin环境中使用 GNU GCC编译器学习 C。

回答by Adam Davis

Simple and sweet: Console applications (basic C programs using printf and such) are easily and cheaply done with the Tiny C Compiler - a no frills, no gui, complete C complier.

简单而甜蜜:控制台应用程序(使用 printf 等的基本 C 程序)可以使用 Tiny C Compiler 轻松且廉价地完成 - 一个没有装饰、没有 gui、完整的 C 编译器。

http://bellard.org/tcc/

http://bellard.org/tcc/

However, C development is relatively simple on Visual Studio as well. The following instructions will set Visual C++ up as a good C compiler, and it will produce console applications at first, and yo can move up into more complex windows apps as you go.

但是,在 Visual Studio 上进行 C 开发也相对简单。下面的说明将把 Visual C++ 设置为一个好的 C 编译器,它首先会生成控制台应用程序,你可以随时升级到更复杂的 Windows 应用程序。

  1. Get the Visual Studio C++ edition (express is fine)
  2. Start a new project - disable pre-compiled headers (maybe the wizard will let you do this, maybe you'll have to change the compiler settings once inside the project)
  3. Delete everything inside the project.
  4. Create a new "example.c" file with the hello world example
  5. Compile and away you go.
  1. 获取 Visual Studio C++ 版本(express 很好)
  2. 启动一个新项目 - 禁用预编译头文件(也许向导会让你这样做,也许你必须在项目内部更改编译器设置)
  3. 删除项目中的所有内容。
  4. 使用 hello world 示例创建一个新的“example.c”文件
  5. 编译并离开。

Alternately, get a linux virtual machine, or Cygwin. But as you already have Visual Studio, you might as well stick with what you know.

或者,获取 linux 虚拟机或 Cygwin。但由于您已经拥有 Visual Studio,您不妨坚持使用您所知道的。

As an aside, this isn't Atwood learning C finally, is it? No ALTs! ;-D

顺便说一句,这不是 Atwood 终于学习 C 了,是吗?没有ALT!;-D

-Adam

-亚当

回答by mmattax

Bloodshed Dev-C++ is the best windows C/C++ IDE IMO: http://www.bloodshed.net/It uses the GNU compiler set and is free as in beer.

Bloodshed Dev-C++ 是最好的 Windows C/C++ IDE IMO:http: //www.bloodshed.net/它使用 GNU 编译器集并且像啤酒一样免费。

EDIT: the download page for the IDE is here: http://www.bloodshed.net/dev/devcpp.html

编辑:IDE 的下载页面在这里:http: //www.bloodshed.net/dev/devcpp.html

回答by codeLes

As already said, you should check out the VS.net C++ edition, but if you'd like to try something else Eclipse has a C++ edition. You can get more info from http://eclipse.orgor check out the distro at http://www.easyeclipse.org/site/distributions/cplusplus.html

如前所述,您应该查看 VS.net C++ 版本,但如果您想尝试其他东西,Eclipse 有一个 C++ 版本。您可以从http://eclipse.org获取更多信息,或者在http://www.easyeclipse.org/site/distributions/cplusplus.html查看发行版

回答by mmattax

The problem with learning C within Visual Studio is that you are compiling C 
using the Visual Studio C++ compiler. You might want to try learning C using
the GNU GCC compiler from within the Cygwin environment in Windows.

This is a legitimate response, I posted an IDE that uses the GNU compilers, so why has he been down modded?

这是一个合理的回应,我发布了一个使用 GNU 编译器的 IDE,那么为什么他被降级了?

This is the type of thing that will make me not useSO, why down mod someone just because they are recommending a different compiler, and IMHO, a better one then Microsoft's?

这是一种让我不使用SO 的东西,为什么仅仅因为他们推荐不同的编译器而对某人进行修改,恕我直言,比微软的更好?

get real people, and @Antonio Haley I gave you +1

找真人,@Antonio Haley 我给了你 +1

回答by Antonio Haley

There's a very good reason to learn C and C++. The reason is that there's a lot of C and C++ code out there that are performing very real and important tasks. Someone who considers themselves a programmer and a learner(doubtful that you can separate the two) can learn a lot from these lines of code.

有一个很好的理由来学习 C 和 C++。原因是有很多 C 和 C++ 代码在执行非常真实和重要的任务。自认为是程序员和学习者的人(怀疑您是否可以将两者分开)可以从这些代码行中学到很多东西。

You can learn a lot from each language by studying the other, but if you really want to grok C it's a lot easier to separate yourself from anything C++ for a while. Visual C++ is great but GCC is a great way to thrust yourself into vanilla ANSI C without having to mentally sidestep any C++.

通过学习另一种语言,您可以从每种语言中学到很多东西,但是如果您真的想了解 C,那么将自己与 C++ 分开一段时间会容易得多。Visual C++ 很棒,但 GCC 是一种很好的方式,可以让你自己进入普通的 ANSI C,而不必在精神上回避任何 C++。

@mmattax thanks!

@mmattax 谢谢!

回答by Antonio Haley

C in Visual Studio is fine, just use the command line compiler that is included in the Pro edition. Yes its the C++ compiler but treats all files ending .c as C . You can even force it to treat ALL files as C with a switch. The VS documentation has entries on it, just search the index for Visual C.

Visual Studio 中的 C 没问题,只需使用 Pro 版中包含的命令行编译器即可。是的,它是 C++ 编译器,但将所有以 .c 结尾的文件视为 C 。您甚至可以强制它使用开关将所有文件视为 C。VS 文档上有条目,只需搜索 Visual C 的索引即可。

回答by devdimi

Visual Studio is one of the best IDEs for C/C++. I don't think it is complicated and hard to use - if you have questions about it - ask them. Some other compilers/IDEs are fine too, but if already have Visual Studio and have used it - why not stick to it?

Visual Studio 是用于 C/C++ 的最佳 IDE 之一。我认为它并不复杂且难以使用 - 如果您对此有疑问 - 问他们。其他一些编译器/IDE 也很好,但是如果已经有了 Visual Studio 并且已经使用过它——为什么不坚持使用它呢?