gpt4 book ai didi

编译器 C99 GNU99

转载 作者:行者123 更新时间:2023-11-30 18:55:36 30 4
gpt4 key购买 nike

任何帮助将不胜感激。提前致谢

我无法使用 kernel.cl 文件中 time.h 中的函数

我的 main.cpp 能够使用包含内容。

我的time.h/usr/include并且我尝试使用std=gnu99,但不知何故它仍然认为我我正在使用 C99

我的 kernel.cl 有

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

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

我的错误是

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

最佳答案

您正在使用德州仪器 (TI) 特定的编译器进行编译,以便与嵌入式设备一起使用。 Linux 上 clock_gettime() 的联机帮助页暗示并非所有 POSIX 系统都实现该 API,并告诉您如何检查:

"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).)"

因此,如果 unistd.h 中的 _POSIX_TIMERS 为 0 或未定义,则该例程在您的设备上无法通过编译器提供的标准库使用。

关于编译器 C99 GNU99,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27325054/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com