Skip to content

Instantly share code, notes, and snippets.

@magnumripper
Last active December 7, 2021 16:15
Show Gist options
  • Save magnumripper/e10fc3617a75f382ca97b97edda44f01 to your computer and use it in GitHub Desktop.
Save magnumripper/e10fc3617a75f382ca97b97edda44f01 to your computer and use it in GitHub Desktop.
#pragma inside a macro

You can't use #pragma within a macro. But in C99, and therefore OpenCL, you can use the _Pragma() directive:

# if foo
#define PRAGMA_UNROLL "_Pragma(unroll 8)"
#elif bar
#define PRAGMA_UNROLL "_Pragma(unroll 16)"
#endif

#define macro foobar(...) \
(...) \
	PRAGMA_UNROLL \
	for (...) \
(...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment