Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using c99 in C++'s `extern "C"` blocks

Tags:

c++

c

gcc

extern

g++

I would like to have a function written in C, but callable from C++ which takes a restricted pointer. This is only available in c99, so g++ doesn't like it, even in extern "C" blocks. How can I get around this limitation?

like image 643
Clark Gaebel Avatar asked Mar 22 '26 12:03

Clark Gaebel


1 Answers

#ifdef __cplusplus
#   ifdef __GNUC__
#       define restrict __restrict__ // G++ has restrict
#   else
#       define restrict // C++ in general doesn't
#   endif
#endif
like image 67
Potatoswatter Avatar answered Mar 25 '26 03:03

Potatoswatter