problem with fprintf and OpenMP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm using gcc-4.9.0 and have a problem with the following program.

#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, but now "stderr" must
be shared, because it is defined in a different way.

linpc1 OpenMP 111 grep stderr /usr/include/stdio.h
extern struct _IO_FILE *stderr;         /* Standard error output stream.  */
#define stderr stderr
linpc1 OpenMP 112 

linpc1 OpenMP 108 \gcc -fopenmp omp_fprintf.c 
omp_fprintf.c: In function 'main':
omp_fprintf.c:45:3: error: 'stderr' not specified in enclosing parallel
   fprintf (stderr, "Hello!\n");
   ^
omp_fprintf.c:44:11: error: enclosing parallel
   #pragma omp parallel default (none)
           ^
linpc1 OpenMP 109 

linpc1 OpenMP 109 \gcc -fopenmp omp_fprintf_shared_stderr.c 
linpc1 OpenMP 110 


Is it possible to solve this problem for "stderr, stdout, ..."
or is it necessary that I implement operating system specific
pragmas in my programs? Thank you very much for any suggestions
and any improvements of gcc (if possible) to solve these problems
in advance.


Kind regards

Siegmar





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux