在C++的`extern "C"`块中使用c99

3

我希望编写一个用C语言编写的函数,但可以从C++中调用,该函数需要接受一个受限指针。这仅在c99中可用,因此即使在extern "C"块中,g++也无法使用它。如何解决这个限制?


3
"extern C"并不意味着其中的代码是C语言,它意味着在那里声明的任何函数或项目将使用C链接。 - Billy ONeal
开个玩笑:尝试使用 extern "C99" - pmg
类似的问题在这里:struct XY a = { .x = 1, .y = 2 }; 在 extern "C" 块内部无法编译通过:_error: expected primary-expression before ‘.’ token_,真是令人沮丧!相反,过时的形式 struct XY a = { x: 1, y: 2 }; 却可以工作。疼! - gatopeich
1个回答

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接