Env:
- gcc version 10.3.1 20210824 (release) (GNU Arm Embedded Toolchain 10.3-2021.10)
- std=c++11
- nRF Connect SDK v2.0.0
Including nrf_socket.h from nrfxlib/nrf_modem/include/ in C++ project causes error because C++ doesn't know keyword restrict
.
nrf_socket.h:626:49: error: expected ',' or '...' before 'buffer' 626 | ssize_t nrf_recvfrom(int socket, void *restrict buffer, size_t length, int flags, | ^~~~~~
Replacing restrict
with __restrict
solved this problem.
C++ does not have standard support for
restrict
, but many compilers have equivalents that usually work in both C++ and C, such as the GCC's and Clang's__restrict__...
In Unix-style compilers such as GCC and Clang,
__restrict
and__restrict__
mean exactly the same as their C counterpart