Bug 37764

Summary: Macro is not passed to openmp pragma when preprocessor is used
Product: gcc Reporter: Geir Johansen <geir>
Component: cAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: minor CC: gcc-bugs
Priority: P3    
Version: 4.3.1   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description Geir Johansen 2008-10-07 22:35:11 UTC
The following openmp test case will not compile when it is first separating
processed by the preprocessor:

$ cat bug2885b.c
#include <omp.h>
#include <stdio.h>
#define NT 4
int actual_num_threads;

int main(){
  #pragma omp parallel default(none) shared(actual_num_threads) num_threads(NT)
  {
      #pragma omp master
      {
          actual_num_threads = omp_get_num_threads();
      }
  }

  printf("actual_num_threads: %d\n",actual_num_threads);
  printf("num_threads NT: %d\n",NT);
  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.

$

    <Works: Not running through the preprocessor separately>

$ gcc -fopenmp bug2885b.c; ./a.out
actual_num_threads: 4
num_threads NT: 4
$

    <Error: Running the preprocessor separately>

$ gcc -E -fopenmp bug2885b.c > bug.c
$ gcc -fopenmp bug.c
bug2885b.c: In function 'main':
bug2885b.c:7: error: 'NT' undeclared (first use in this function)
bug2885b.c:7: error: (Each undeclared identifier is reported only once
bug2885b.c:7: error: for each function it appears in.)
bug2885b.c:7: error: expected integer expression before end of line
$
Comment 1 Andrew Pinski 2008-10-07 22:51:59 UTC

*** This bug has been marked as a duplicate of 37023 ***