This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PROCESSOR-SDK-DRA8X-TDA4X: C99 restrict qualifier in TIADALG #ifdef __cplusplus

Part Number: PROCESSOR-SDK-DRA8X-TDA4X

Hi,

We're using PSDKRA v7.1.0. If call TIADALG in C++,  make vision_apps output:

[GCC] Compiling C++ main.cpp
[GCC] Compiling C99 app_pre_proc_module.c
[GCC] Compiling C99 main.c
[GCC] Compiling C99 app_pre_proc_module.c
[GCC] Compiling C99 app_post_proc_module.c
In file included from /home/keelung/ti/psdk/rtos/tiadalg/include/tiadalg_interface.h:72,
                 from /home/keelung/ti/psdk/rtos/vision_apps/apps/dl_demos/app_tidl_od_cpp/app_pre_proc_module.h:68,
                 from /home/keelung/ti/psdk/rtos/vision_apps/apps/dl_demos/app_tidl_od_cpp/main.cpp:77:
/home/keelung/ti/psdk/rtos/tiadalg/include/../tiadalg_select_top_feature/inc/tiadalg_select_top_feature.h:232:55: error: expected ‘,’ or ‘...’ before ‘desc_a_list’
  232 | int32_t tiadalg_select_top_feature_c66(void *restrict desc_a_list,
      |                                                       ^~~~~~~~~~~
/home/keelung/ti/psdk/rtos/vision_apps/apps/dl_demos/app_tidl_od_cpp/main.cpp: In function ‘vx_status app_run_graph(AppObj*)’:
/home/keelung/ti/psdk/rtos/vision_apps/apps/dl_demos/app_tidl_od_cpp/main.cpp:1131:18: warning: comparison of integer expressions of different signedness: ‘vx_int32’ {aka ‘int’} and ‘vx_uint32’ {aka ‘unsigned int’} [-Wsign-compare]
 1131 |     for(x = 0; x < obj->num_iterations; x++)
      |                ~~^~~~~~~~~~~~~~~~~~~~~
concerto/finale.mak:308: recipe for target '/home/keelung/ti/psdk/rtos/vision_apps/out/J7/A72/LINUX/release/module/apps.dl_demos.app_tidl_od_cpp/main.o' failed
make[1]: *** [/home/keelung/ti/psdk/rtos/vision_apps/out/J7/A72/LINUX/release/module/apps.dl_demos.app_tidl_od_cpp/main.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/keelung/ti/psdk/rtos/vision_apps'
Makefile:159: recipe for target 'vision_apps' failed
make: *** [vision_apps] Error 2

So I've to replace restrict by __restrict at line 76 in tiadalg_select_top_feature.h as a temporary solution.

#ifdef __cplusplus
#define restrict __restrict
extern "C" {
#endif

According to https://en.wikipedia.org/wiki/Restrict

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__, and Visual C++'s __declspec(restrict). In addition, __restrict is supported by those three compilers.

and http://www.open-std.org/JTC1/SC22/wg21/docs/papers/2014/n3988.pdf

C99 restrict qualifier support is not part of C++11

So maybe using __restrict directly is better then restrict in practice? Although __restrict is not a keyword in C standards.