代码之家  ›  专栏  ›  技术社区  ›  Clark Gaebel

C99在C++的“外部”C“块”中的使用

  •  3
  • Clark Gaebel  · 技术社区  · 15 年前

    我希望有一个用C编写的函数,但是可以从C++中调用一个带限制指针的函数。这只在C99中可用,所以G++不喜欢它,即使在 extern "C" 阻碍。我怎样才能绕过这个限制呢?

    1 回复  |  直到 15 年前
        1
  •  1
  •   Potatoswatter    15 年前
    #ifdef __cplusplus
    #   ifdef __GNUC__
    #       define restrict __restrict__ // G++ has restrict
    #   else
    #       define restrict // C++ in general doesn't
    #   endif
    #endif