通过 Android NDK 编译 C++ 文件时出错

Error during compile c++ file through Android NDK

我尝试编译一些库并得到错误:

In file included from *************************:
F:/include/strutils.h:40:37: error: expected ';', ',' or ')' before 'dest'
 extern void *mempcpy(void *restrict dest, const void *restrict src, size_t n);

这是strutils.h:

#ifndef HAVE_MEMPCPY
extern void *mempcpy(void *restrict dest, const void *restrict src, size_t n);
#endif

怎么了?

它不识别单词 restrict。

如果是C文件,你可能需要指定一个命令行开关来告诉它识别C99关键字。 https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html

或者,

#define restrict

或者可能

#define restrict __restrict__

如果 strutils.h 包含在 .cpp 文件中: C++ does not have standard support for restrict, but many compilers have equivalents which usually work in both C++ and C, such as the GNU Compiler Collection __restrict__