OpenCL:标头文件的其他目录 [英] OpenCL: Additional directories for header files

查看:113
本文介绍了OpenCL:标头文件的其他目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OpenCL规范写在 5.6.3构建选项中:

The OpenCL specification writes in 5.6.3 Build Options:

...  
-I dir  
    Add the directory dir to the list of directories to be searched  
    for header files.

有人可以解释一下这是什么意思吗?据我所知,您无法将头文件包含到OpenCL内核中.那么,这个选项有什么用呢?

Can someone please explain what that means? As far as I know you cannot inlcude header files into your OpenCL kernels. So what could this options be for?

链接到OpenCL规范: http://www. khronos.org/registry/cl/specs/opencl-1.1.pdf

Link to the OpenCL spec: http://www.khronos.org/registry/cl/specs/opencl-1.1.pdf

我在错误的假设下,不允许将头文件包含在OpenCL内核中.现在,我有了jHackTheRipper的帮助.

I was under the wrong assumption that it is not allowed to include header files into ones OpenCL kernel. Now I know better, thanks to jHackTheRipper.

推荐答案

它允许您添加一些包含标头文件的目录,这些目录不在标准的include-search路径中.这样,您可以告诉编译器那些特定的头文件在系统上的位置.

It allows you to add some directories containing header files which are not in the standard include-search path. This way you can tell the compiler where those particular header files are located on your system.

例如,假设文件foo.h不在标准的include路径中(在Unix系统中通常为/usr/include),但是在/home/foo/my_headers/foo.h中,您可以要求编译器搜索/home/foo/my_headers通过执行以下操作来获取头文件:

For instance, suppose the file foo.h is not in the standard include path (commonly /usr/include on a Unix system), but rather in /home/foo/my_headers/foo.h, you can ask the compiler to search /home/foo/my_headers for header files by doing:

g++ -I/home/foo/my_headers foo.c -o foo

为完整起见,本节的标题引入了预处理器一词,这是在编译器之前调用的程序,用于将所有#something指令替换为它们的等价物. #include <foo.h>将替换为foo.h文件的内容.

To be complete, the section title introduce the word preprocessor which is the program called before the compiler to replace all #something directives by their equivalent. #include <foo.h> will be replaced by the content of the foo.h file.

这篇关于OpenCL:标头文件的其他目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆