vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi to everybody, sorry if this is not the best place to post this message. Please if you know other newsgroups more focused for that let me know. Thx. I am trying to use _Pragma operator inside a macro without success. For instance XLC v7.0 is not able to compile the next code: #include <stdio.h> #include <stdlib.h> #define test_macro( ) \ _Pragma( "omp parallel for private(i)" ) \ for (i= 0; i< 2; i++) \ { \ printf("I am thread %d OMP\n", omp_get_num_thread()); \ } int main( void ) { int i; test_macro(); _Pragma( "omp parallel for private(i)" ) for (i= 0; i< 2; i++) { printf("I am thread %d OMP\n", omp_get_num_thread()); }; return 0; } test_macro should be expanded to the same source code that the next line in the main function. I know that _Pragma operator is expanded to a pragma sentence by compiler and not by preprocessor. The problem is as follows, if I try to compile this short sample I get the next error: % xlc_r -q64 -O3 -qtune=ppc970 -qarch=ppc970 -qmaxmem=-1 -qsmp=omp -c ex.c "ex.c", line 15.15: 1506-276 (S) Syntax error: possible missing 'for'? It is saying that '#pragma omp parallel for' is not followed by a 'for' sentence, and this is false. On the other hand if first we try to preprocess and later we try to compile the preprocessed file we get the object file ex.o without problems. Furthermore, in the preprocessed file (ex.i) we can see that both lines in main match (test_macro & _Pragma). % xlc_r -q64 -O3 -qtune=ppc970 -qarch=ppc970 -qmaxmem=-1 -qsmp=omp -E ex.c &> ex.i xlc_r -q64 -O3 -qtune=ppc970 -qarch=ppc970 -qmaxmem=-1 -qsmp=omp -c ex.i So, the problem is in the _Pragma operator inside macros. Anybody know where is the problem? A workaround about this? I take some days trying to solve this error. Thx in advance, Regards! -- My current project: Tuning for IBM PowerPC 970-based Blades (http://www.ciri.upc.es/pblade_tuning) ---------------------------------------------------------------------- Copyright protects software. Patents protect software monopolies. -- NO to software patents (http://swpat.ffii.org) ---------------------------------------------------------------------- o//o Raúl de la Cruz Martínez E-mail: delacruz at ac upc es o//o CEPBA-IBM Research Institute (CIRI) http://www.ciri.upc.es o//o http://people.ac.upc.es/delacruz Tel: +34 93-401 16 49 o//o CIRI C/Jordi Girona 1-3, Despatx C6-S103. BCN, Catalonia, SPAIN ---------------------------------------------------------------------- |