如何在 Mac 上编写 C++?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21733019/
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 23:47:41  来源:igfitidea点击:

How to write C++ on Mac?

c++iosmacos

提问by user3302376

Taking my first C++ class in college. I need to download C++ and my teacher gave us a direct link to download it, but it only works on Windows. Is there a way I can format it to work on my Mac or is there a Mac-friendly version I can download?

我在大学里上第一堂 C++ 课。我需要下载 C++,我的老师给了我们一个直接下载链接,但它只适用于 Windows。有没有办法格式化它以在我的 Mac 上工作,或者是否有我可以下载的 Mac 友好版本?

回答by OJFord

A compiler for C++ is already built into Mac (try g++ main.cppin terminal). If you mean an IDE for C++, use Xcode 5, available in app store.

C++ 的编译器已经内置到 Mac 中(g++ main.cpp在终端中尝试)。如果您指的是用于 C++ 的 IDE,请使用Xcode 5,可在应用商店中获得。

It's developed by Apple, has git integration too if that's useful to you. Also has templates and such available to entice you to work on OS X/iOS projects, which might be a nice way in for you (I'm just starting out too, and I think that could be good).

它是由 Apple 开发的,如果对你有用的话,它也有 git 集成。也有模板等可用来吸引您从事 OS X/iOS 项目,这对您来说可能是一个不错的方式(我也刚刚开始,我认为这可能很好)。

For command-line projects though, I find it best to write in Xcode, then compile and run from the terminal. It's easier for file I/O and passing arguments to stdin IMO.

不过,对于命令行项目,我发现最好用 Xcode 编写,然后从终端编译和运行。文件 I/O 和将参数传递给 stdin IMO 更容易。

回答by Sudeep Devkota

You can utilize something called Xcode IDE to write your programs on C++, I have been using that for a quite a while now, and it's definitely fun. You can find the app from free on APP store or just by clicking the link below. This is one of the many things I like about MAC.

您可以使用称为 Xcode IDE 的东西在 C++ 上编写您的程序,我已经使用它有一段时间了,这绝对很有趣。您可以在 APP 商店中免费找到该应用程序,或者只需单击下面的链接即可。这是我喜欢 MAC 的众多优点之一。

click here to get XCODE

单击此处获取 XCODE

回答by Ferris Garden

I think you kinda have the wrong idea of c++. C++ is a programming language and what you are asking about is a development environment. For example Xcode is such an environment. Since I also have my favorite I would use Eclipse since it is useful for many other purposes too.

我认为您对 C++ 有一些错误的想法。C++ 是一种编程语言,您要问的是开发环境。比如Xcode就是这样的环境。因为我也有我最喜欢的,所以我会使用 Eclipse,因为它对许多其他目的也很有用。

Eclipse C++ Download

Eclipse C++ 下载

回答by ak_2050

On Mac, since you are just starting out, use XCode. Its a pretty neat IDE with built in C++ compiler so you can write C++, compile with a click and run.

在 Mac 上,由于您刚刚开始,请使用 XCode。它是一个非常简洁的 IDE,内置 C++ 编译器,因此您可以编写 C++,单击并运行编译。