OpenCL-CLHPP icon indicating copy to clipboard operation
OpenCL-CLHPP copied to clipboard

X11/X.h macro replaces 'None'

Open ODON1 opened this issue 4 years ago • 1 comments

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

ODON1 avatar Dec 09 '21 20:12 ODON1

@ODON1 Indeed, that error came up a long time ago and was not caught by CI at the time. Changing the name of that enum entry is a breaking change and one we should investigate. This workaround had to be baked into the recently released OpenCL-SDK samples too.

MathiasMagnus avatar Jan 03 '22 09:01 MathiasMagnus