KhronosGroup / KhronosGroup/OpenCL-CLHPP
X11/X.h macro replaces 'None'
- Dominant language
- C++
- Stars
- 425
- Forks
- 133
- Avg merge
- 3h 30m
- Merged PRs (30d)
- 1
Description
Depending on the order of includes I get the following error:
```
In file included from /home/otto/Documents/Programming/Interop/tests/testOpenCL.cpp:1:
In file included from /home/otto/Documents/Programming/Interop/tests/testOpenCL.h:20:
/usr/local/include/CL/opencl.hpp:7101:5: error: expected identifier
None = 0,
^
/usr/include/X11/X.h:115:30: note: expanded from macro 'None'
#define None 0L /* universal null resource or null atom */
^
In file included from /home/otto/Documents/Programming/Interop/tests/testOpenCL.cpp:1:
In file included from /home/otto/Documents/Programming/Interop/tests/testOpenCL.h:20:
/usr/local/include/CL/opencl.hpp:8852:5: error: expected identifier
None = 0,
^
/usr/include/X11/X.h:115:30: note: expanded from macro 'None'
#define None 0L /* universal null resource or null atom */
^
In file included from /home/otto/Documents/Programming/Interop/tests/testOpenCL.cpp:1:
In file included from /home/otto/Documents/Programming/Interop/tests/testOpenCL.h:20:
/usr/local/include/CL/opencl.hpp:8902:67: error: expected unqualified-id
DeviceQueueProperties properties = DeviceQueueProperties::None,
^
/usr/include/X11/X.h:115:30: note: expanded from macro 'None'
#define None 0L /* universal null resource or null atom */
^
In file included from /home/otto/Documents/Programming/Interop/tests/testOpenCL.cpp:1:
In file included from /home/otto/Documents/Programming/Interop/tests/testOpenCL.h:20:
/usr/local/include/CL/opencl.hpp:8927:67: error: expected unqualified-id
DeviceQueueProperties properties = DeviceQueueProperties::None,
^
/usr/include/X11/X.h:115:30: note: expanded from macro 'None'
#define None 0L /* universal null resource or null atom */
^
```
I saw a mention of the same problem here [(https://bugs.webkit.org/show_bug.cgi?id=200984)]
/usr/include/X11/X.h has the following lines:
```
*****************************************************************
* RESERVED RESOURCE AND CONSTANT DEFINITIONS
*****************************************************************/
#ifndef None
#define None 0L /* universal null resource or null atom */
#endif
#define ParentRelative 1L /* background pixmap in CreateWindow
and ChangeWindowAttributes */
#define CopyFromParent 0L /* border pixmap in CreateWindow
and ChangeWindowAttributes
special VisualID and special window
class passed to CreateWindow */
```
This 'None' macro is apparently still active when processing opencl.hpp and replaces some enums.
(Maybe this should be solved by X11?)
I solved it by adding "#undef None" to the head of the opencl.hpp file but that may not be the best solution
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the None enum and default arguments in opencl.hpp, then reproduce the include-order failure from tests/testOpenCL.cpp and tests/testOpenCL.h using the reported X11 and OpenCL headers. Determine a compatibility fix that prevents X11's None macro from replacing OpenCL identifiers, and verify that the affected declarations compile in both include orders.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100