简体   繁体   中英

Compilers C99 GNU99

Any help will be really appreciated. Thanks in advance

I am not able to use the functions in time.h inside my kernel.cl file

My main.cpp is able to use the includes.

My time.h is is /usr/include and I have tried using std=gnu99 , but somehow it is still thinking I am using C99

My kernel.cl has

#include "time.h"                                                               
#define _POSIX_C_SOURCE >= 199309L**** 

.....
.....
struct timespec tp_start, tp_end;                                              
clock_gettime(CLOCK_MONOTONIC, &tp_start);

And my errors are

g++  -c -O3 -fopenmp -I/usr/include main.cpp

echo Compiling main.cpp

Compiling main.cpp

cl6x -mv6600 --abi=eabi -I/include  -I/usr/share/ti/cgt-c6x/include -I/usr/share/ti/opencl -I/usr/include  -c -o3 ccode.c

echo Compiling ccode.c

Compiling ccode.c

clocl  -I/usr/include -std=gnu99  kernel.cl ccode.obj

kernel.cl:50:17: error: variable has incomplete type 'struct timespec'

kernel.cl:50:8: note: forward declaration of 'struct timespec'

kernel.cl:50:27: error: variable has incomplete type 'struct timespec'

kernel.cl:50:8: note: forward declaration of 'struct timespec'

kernel.cl:51:1: warning: implicit declaration of function 'clock_gettime' is invalid in C99

kernel.cl:51:15: error: use of undeclared identifier 'CLOCK_MONOTONIC

You are compiling with a Texas Instruments-specific compiler for use with an embedded device. The manpage for clock_gettime() on Linux implies not all POSIX systems implement the API, and tells how to check:

"On POSIX systems on which these functions are available, the symbol _POSIX_TIMERS is defined in to a value greater than 0. The symbols _POSIX_MONOTONIC_CLOCK, _POSIX_CPUTIME, _POSIX_THREAD_CPUTIME indicate that CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID are available. (See also sysconf(3).)"

So, if _POSIX_TIMERS in unistd.h is 0 or is undefined, that routine is not available on your device with the standard library provided with the compiler.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM