This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/37023] New: Macro replacement not working if file is preprocessed then compiler
- From: "geir at cray dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Aug 2008 20:37:16 -0000
- Subject: [Bug c/37023] New: Macro replacement not working if file is preprocessed then compiler
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following program shows two cases where macro replacement works if the
program is compiled, but does NOT work if the program is preprocessed and then
compiled. Either the preprocessed program should be able to be compiled, or
gcc should return an error when the non-preprocessed code is compiled.
$ cat ISU3006.c
/* derived from ISU's RTED_OpenMP/C/Col7_Imp_Dep_Errs/c_G_1_1_a.c */
/* Trying c99 _Pragma possibility */
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
#define NT 4
#define N 17
#ifdef TEST3
#define NTM(x) #x
#define PRAGMA(x) NTM(omp parallel default(none) shared(vara,
actual_num_threads) num_threads(x) )
#define LISTING(x) _Pragma(x)
#endif
int actual_num_threads;
int main(){
int vara=0;
#ifdef TEST3
LISTING(PRAGMA(NT))
#elif TEST2
_Pragma ( "omp parallel default(none) shared(vara, actual_num_threads)
num_threads(NT)" )
#else /*TEST1*/
#pragma omp parallel default(none) shared(vara, actual_num_threads)
num_threads(NT)
#endif
{
#pragma omp master
{
actual_num_threads = omp_get_num_threads();
vara = 10 + actual_num_threads;
}
}
printf("calculate vara: %d\n",vara);
return 0;
}
$ gcc --version
gcc (GCC) 4.3.1 20080606 (rpm:5)
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gcc -fopenmp ISU3006.c
$ gcc -DTEST2 -fopenmp ISU3006.c
$ gcc -E -fopenmp ISU3006.c >i1.i
$ gcc -fopenmp i1.i
ISU3006.c: In function 'main':
ISU3006.c:26: error: 'NT' undeclared (first use in this function)
ISU3006.c:26: error: (Each undeclared identifier is reported only once
ISU3006.c:26: error: for each function it appears in.)
ISU3006.c:26: error: expected integer expression before end of line
$ grep parallel i1.i
extern int omp_in_parallel (void) __attribute__((__nothrow__));
#pragma omp parallel default(none) shared(vara, actual_num_threads)
num_threads(NT)
$ gcc -DTEST2 -E -fopenmp ISU3006.c >i2.i
$ gcc -fopenmp i2.i
ISU3006.c: In function 'main':
ISU3006.c:24: error: 'NT' undeclared (first use in this function)
ISU3006.c:24: error: (Each undeclared identifier is reported only once
ISU3006.c:24: error: for each function it appears in.)
ISU3006.c:24: error: expected integer expression before end of line
$ grep parallel i2.i
extern int omp_in_parallel (void) __attribute__((__nothrow__));
#pragma omp parallel default(none) shared(vara, actual_num_threads)
num_threads(NT)
$
Here is code that allows the program to be compiled when first running it
through the preprocessor:
$ gcc -DTEST3 -fopenmp ISU3006.c
$ gcc -DTEST3 -E -fopenmp ISU3006.c >i3.i
$ gcc -fopenmp i3.i
$ grep parallel i3.i
extern int omp_in_parallel (void) __attribute__((__nothrow__));
#pragma omp parallel default(none) shared(vara, actual_num_threads)
num_threads(4)
$
--
Summary: Macro replacement not working if file is preprocessed
then compiler
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: geir at cray dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37023