c++ - Visual Studio 问题/C++

标签 c++ visual-studio visual-studio-2010 visual-c++

我是一名开发爱好者,具有 Java 背景(选择的 IDE 是 Eclipse)。我正在使用 Visual Studio Express 2010 并想学习 C++。

几个问题:

  • 我用 C++ 创建了一个“HelloWorld”,并在 VS/Windows 中编译/运行。当我尝试在 Linux/GCC 下编译它时,它显然会抛出大量错误。默认 Windows 控制台项目包括特定于 Windows 的文件;但如果只是创建一个“空项目”,它会抛出大量的链接器/构建错误。保持代码可移植性的最佳做法是什么?

  • 为什么 8 行代码创建 47 个文件?

  • 您如何格式化代码?您可以执行“编辑”->“格式选择”,但热键不起作用?

  • 如何输出到 VS 的“输出”窗口? (就像运行控制台 Java 应用程序时 eclipse 所做的那样)

  • 每次我重新启动时,它都会将我的“项目位置”恢复到我的“主目录”。你如何改变它?这是一个错误吗?因为它是 Express 版?

  • 有没有办法让它在运行时不切换到调试 View ?

最佳答案

I create a "HelloWorld" in C++ and compiles/runs in VS/Windows. When I try to compile it under Linux/GCC, it obviously throws tons of errors. Default windows console project includes windows specific files; but if just create an "Empty Project" it throws tons of linker/build errors. What's the best practices here to keep my code portable?

对于可移植代码,完全避免使用 VS 向导。如果您从石头和棍子开始,或者使用您喜欢的可移植构建系统(Ant、CMake 等),请使用 Make/NMake。其中一些会生成一个 VS 解决方案/项目文件供您使用。

Why is it creating 47 files for 8 lines of code?

巫师就是这样神奇。

How do you format code? You can do Edit->Format Selection, but the hotkeys don't work?

Ctrl-K Ctrl-F(在编辑、高级下)

How do I output to VS's 'Output' Window? ( like eclipse does when you run a console java app )

查找调试窗口的 OutputDebugString()。输出窗口应获得所有 cout/cerr 输出。

It keeps reverting my "Project Location" to my "home directory" every time I restart. How do you change it? Is it a bug? Because it's Express edition?

可能隐藏在某处的选项中 - 不知道那个,抱歉。

Is there a way to keep it from switching to Debug view when it runs?

使用 Ctrl+F5 启动以在不附加调试器的情况下运行。

玩得开心!

关于c++ - Visual Studio 问题/C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5643849/

相关文章:

c# - 解析器错误消息 : 'FCR2.abs' is not allowed here because it does not extend class 'System.Web.UI.Page'

c++ - 有谁知道在 C/C++ 中使用 libevent 实现 Web 套接字 API 的任何尝试?

c++ - nm 报告的未解析符号

visual-studio-2010 - 默认浏览器 - Visual Web Developer Express 2010

visual-studio - 在 Visual Studio 中查看拉取请求的审阅评论

c# - Visual C# 中的全局变量

visual-studio - 用于在 Visual C++ 中配置构建的自定义宏

c++ - 为什么模板不能在 extern "C" block 内?

c++ - C++ socket.http 中嵌入的 LUA [错误 : attempt to call a nil value]

visual-studio - 什么是 TypeScript 项目构建配置选项?