[c/c++互相包含困惑]c文件包含c++头文件
expected ';', ',' or ')' before '&' token
expected declaration specifiers or '...' before 'UsFileOpenMode'
情况是这样的:
有以下文件:
cfile.c
cppfile1.cpp
cppfile1.h
cppfile2.cpp
在cppfile2.cpp中 #include "cppfile1.h" 就完全正常,没有任何问题
但是如果在cfile.c中 #include "cppfile1.h" 就会报出以上那些错误
所以想请教:
是因为c++的头文件不能被 c文件包含么?
如果是这样,是因为 c编译器无法识别c++编译器标识的函数吗?
另外,引申出来的问题:
1. c++ 使用 c 的文件,需要在c的头文件里加 extern "C" {}
2. c 使用 c++的文件,是要在c++ 头文件和实现文件里 也加 extern "c" 吗?
这样,其它 c++文件在使用这个 c++头文件时,ok吗?
3. 还有其它什么注意事项,也请多多指点 多谢!
相关推荐
C++的头文件互相包含的问题
C++的头文件互相包含的问题。比较有用的解决办法。
VSCode添加头文件(C/C++)的实现示例
Enable pretty-printing for gdb
VSCode配置C/C++并添加非工作区头文件的方法
主要介绍了VSCode配置C/C++并添加非工作区头文件的方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
C/C++头文件大全
#include <assert h> 设定插入点 #include <ctype h> 字符处理 #include <errno h> 定义错误码 #include <float h> 浮点数处理 #include <fstream h> 文件输入/输出 #include <iomanip h> 参数化输入/输出 #include <iostream h> 数据流输入/输出 #include <limits h> 定义各种数据类型最值常量 #include <locale h> 定义本地化函数 #include <math h> 定义数学函数 #include <stdio h> 定义输入/输出函数 #include <stdlib h> 定义杂项函数及内存分配函数 #include <string h> 字符串处理 #include <strstrea h> 基于数组的输入/输出 #include <time h> 定义关于时间的函数 #include <wchar h> 宽字符处理及输入/输出 #include <wctype h> 宽字符分类 int spawnvpe int mode char pathname char argv[] char envp[] spawn函数族在mode模式下运行子程序pathname 并将参数 arg0 arg1 arg2 argv[] envp[] 传递给子程序 出错返回 1 mode为运行模式 mode为 P WAIT 表示在子程序运行完后返回本程序 P NOWAIT 表示在子程序运行时同时运行本程序 不可用 P OVERLAY表示在本程序退出后运行子程序 在spawn函数族中 后缀l v p e添加到spawn后 所指定的函数将具有某种操作能力 有后缀 p时 函数利用DOS的PATH查找子程序文件 l时 函数传递的参数个数固定 v时 函数传递的参数个数不固定 ">#include <assert h> 设定插入点 #include <ctype h> 字符处理 #include <errno h> 定义错误码 #include <float h> 浮点数处理 #include <fstream h> 文件输入/输出 #include <iomanip h& [更多]
C语言头文件包含关系分析工具
c# 简易绘制C语言头文件包含关系图 详细说明可以查看我的blog http://www.cnblogs.com/geeking/ 本工具使用了DotNetBar中的TreeGX控件。下载地址: http://down2.cr173.com/soft1/DotNetBarSetup.zip


