This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: problem with fprintf and OpenMP
- From: Leif Leonhardy <not dot really at online dot de>
- To: gcc at gcc dot gnu dot org
- Cc: Siegmar Gross <Siegmar dot Gross at informatik dot hs-fulda dot de>
- Date: Thu, 15 May 2014 10:09:35 +0200
- Subject: Re: problem with fprintf and OpenMP
- Authentication-results: sourceware.org; auth=none
- References: <201405150601 dot s4F61DKf015468 at tyr dot informatik dot hs-fulda dot de>
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