OpenCL: Additional directories for header files

2019-07-18 09:09发布

The OpenCL specification writes in 5.6.3 Build Options:

5.6.3.1 Preprocessor options

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

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?

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

EDIT2: 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.

2条回答
\"骚年 ilove
2楼-- · 2019-07-18 10:03

I include the headers for development, but for releases I process all of the headers and dependencies into one file, and then embed that source in the binary.

查看更多
The star\"
3楼-- · 2019-07-18 10:07

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.

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

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.

查看更多
登录 后发表回答