简体   繁体   English

如何告诉 Visual Studio 我的 header 应该是 C++ 而不是 C?

[英]How do I tell Visual Studio that my header should be C++ and not C?

I have a C++ project, and the main file with the main function is a .c , but when I include my .h that is supposed to be C++, I think I am getting errors because it thinks it is C. I have a C++ project, and the main file with the main function is a .c , but when I include my .h that is supposed to be C++, I think I am getting errors because it thinks it is C. How can I tell it that my header should be C++ and not C, like my main?我怎么能告诉它我的 header 应该是 C++ 而不是 C,就像我的主?

You cannot #include C++ header in a C source file.您不能在 C 源文件中#include C++ header。 A header is not compiled separately. A header 没有单独编译。 All that #include does - it makes the compiler work as if the header was a part of the file. #include所做的一切 - 它使编译器像 header 是文件的一部分一样工作。

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

相关问题 (Visual Studio)如何知道我的c ++程序中哪些部分已运行,哪些未运行? - (Visual Studio) How can I tell which parts of my c++ program ran and which didn't? 如何将Visual Studio for Windows中制作的C ++解决方案转移到Visual Studio for Mac? - How do I transfer my C++ solution made in Visual Studio for Windows to Visual Studio for Mac? 如何在 Visual Studio 2017 中为 C++ 控制台应用程序添加 header 文件 - How do I add header file for a C++ console app in Visual Studio 2017 如何在Visual Studio C ++项目中找到iostream头文件? - How do I find the iostream header file in a Visual Studio C++ project? 我如何在Visual Studio中的目录内显示C ++头文件 - how do i display c++ header files inside directories in visual studio 我应如何在C ++ Visual Studio Project中包括Bond? - How Should I Include Bond in C++ Visual Studio Project? 使用C ++进行VSPackage开发,启动Visual Studio时如何初始化我的包 - VSPackage development using C++, how do i initialize my package when start visual studio 如何安装此控制台库? Visual Studio C ++ - How do I install this console library? visual studio c++ 如何在 Visual Studio 中打开 C++ 项目文件夹? - How do I open a c++ project folder in visual studio? 如何在 Visual Studio C++ 中增加堆栈大小? - How do I increase the stack size in Visual Studio C++?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM