This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problem with fprintf and OpenMP


On 15.05.2014 08:01, Siegmar Gross wrote:
#include <stdio.h>
#include <stdlib.h>
#include <omp.h>

int main (void)
{
   #pragma omp parallel default (none)
   fprintf (stderr, "Hello!\n");
   return EXIT_SUCCESS;
}


I get the following error, when I try to compile the program
on "Solaris 10 Sparc".

tyr OpenMP 116 \gcc -fopenmp omp_fprintf.c
In file included from /usr/include/stdio.h:66:0,
                  from omp_fprintf.c:38:
omp_fprintf.c: In function 'main':
omp_fprintf.c:45:12: error: '__iob' not specified in enclosing parallel
    fprintf (stderr, "Hello!\n");
             ^
omp_fprintf.c:44:11: error: enclosing parallel
    #pragma omp parallel default (none)
            ^
tyr OpenMP 117


I can solve the problem if I add "shared(__iob)" to "#pragma",
but then the program isn't portable any longer.

tyr OpenMP 118 grep stderr /usr/include/iso/stdio_iso.h
#define stderr  (&__iob[2])
#define stderr  (&_iob[2])
tyr OpenMP 119


I have a similar problem with Linux and Mac OS X, which  need
a different solution, because "stderr" is defined in a different
way.

To get around this, you can add

  FILE *fp=stderr;

and use fp instead of stderr, also adding shared(fp).


-leif


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]