c - How can I use macro expansion for the first identifier of a pragma? -
if wanted define first identifier of pragma how this?
for example, need work openmp pragma:
#define foo omp #pragma foo parallel so need interpreted as:
#pragma omp parallel i'm using gcc in linux. i've read far looks isn't supported. there sort of workaround?
since c99 have _pragma operator, allows place contents of #pragma everywhere, not on line of own, , have subject macro expansion. like
#define stringify_(...) #__va_args__ #define stringify(...) stringify_(__va_args__) #define foo omp #define parallel(...) _pragma(stringify(foo parallel __va_args__)) and then
parallel(private(a)) for(size_t = 0; < num; ++i) .... should trick.
if interested in using such stuff (compared writing these macros) use p99 preprocessor blocks implements things p99_parallel_for , p99_parallel_forall these kind of tricks.
Comments
Post a Comment