KhronosGroup/OpenCL-Headers
FreeKhronos OpenCL-Headers
FreeFree tier
About KhronosGroup/OpenCL-Headers
OpenCL-Headers is the official Khronos Group repository containing C language headers for the OpenCL API. It provides unified headers that support all released OpenCL versions, from OpenCL 1.0 to the latest OpenCL 3.0. The repository includes CMake build support for easy integration into development workflows. Developers can target a specific OpenCL version by defining the CL_TARGET_OPENCL_VERSION preprocessor macro and control which function prototypes are declared using defines like CL_NO_PROTOTYPES, CL_NO_CORE_PROTOTYPES, and CL_NO_EXTENSION_PROTOTYPES. This project is part of the broader OpenCL SDK and is licensed under an open-source license.
Key Features
C language headers for the OpenCL API
Unified headers supporting all OpenCL versions (1.0–3.0)
Target specific OpenCL version via CL_TARGET_OPENCL_VERSION macro
Control function prototypes with CL_NO_PROTOTYPES, CL_NO_CORE_PROTOTYPES, CL_NO_EXTENSION_PROTOTYPES
CMake build system integration for installation and packaging
Part of the OpenCL SDK
Open source under MIT-like license (see LICENSE file)
Pros & Cons
Pros
- Official and authoritative headers from the Khronos Group
- Unified headers reduce complexity across OpenCL versions
- Flexible version targeting and prototype control via preprocessor defines
- Well-documented build process with CMake
- Actively maintained on GitHub with community contributions
Cons
- Headers only — no implementation or runtime included
- Requires understanding of OpenCL API and preprocessor directives
- May need additional setup for non-standard build environments
Best For
Developing OpenCL applications in C/C++Building the OpenCL SDK from sourceTargeting a specific OpenCL version for backward compatibilityCreating custom builds that limit exposed API functions
FAQ
What is OpenCL-Headers?
OpenCL-Headers is the official repository for C language headers of the OpenCL API, maintained by the Khronos Group.
How do I target a specific OpenCL version?
Define the CL_TARGET_OPENCL_VERSION macro before including the headers. For example, #define CL_TARGET_OPENCL_VERSION 120 restricts to OpenCL 1.2 APIs.
Can I control which function prototypes are declared?
Yes, use CL_NO_PROTOTYPES to disable all prototypes, CL_NO_CORE_PROTOTYPES for core APIs, or CL_NO_EXTENSION_PROTOTYPES for extension APIs.
How do I build and install the headers?
Use CMake: run 'cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/path' then 'cmake --build build --target install'.
Are these headers compatible with older OpenCL versions?
Yes, the unified headers support all released OpenCL versions. Use CL_TARGET_OPENCL_VERSION to restrict to an older version.