c++ - 在 C+ +'s ` extern "C"` block 中使用 c99

标签 c++ c gcc g++ extern

我想要一个用 C 编写的函数,但可以从 C++ 调用,它采用受限指针。这仅在 c99 中可用,因此 g++ 不喜欢它,即使在 extern "C" block 中也是如此。我怎样才能绕过这个限制?

最佳答案

#ifdef __cplusplus
#   ifdef __GNUC__
#       define restrict __restrict__ // G++ has restrict
#   else
#       define restrict // C++ in general doesn't
#   endif
#endif

关于c++ - 在 C+ +'s ` extern "C"` block 中使用 c99,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3689239/

相关文章:

c++ - 整个程序的变量访问

python - 尝试编译 Yolo 时,出现找不到包错误

c++ - 将临时变量绑定(bind)到视觉上的非 const 引用编译

c - C 中右移的奇怪行为(有时是算术,有时是逻辑)

linux - gcc 生成具有执行权限的共享对象

Python 扩展 : using different compiler flags for a C parts and C++ parts

c++ - uuid_generate_random (libuuid) 在 solaris 上

c - 分组中的单独字节

c - 如何在 FreeRTOS 中重新启动任务

linux - gcc 是否有任何选项可以在 ELF 二进制文件中添加版本信息?