Hi, I'm using gcc-4.9.0 and have a problem with the following program. I have reported the problem allready on gcc-help some days ago, but didn't get any replies. Perhaps somebody in this list knows, if the behaviour is intended.
#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. In my opinion the compiler knows that I use OpenMP and that I use "default(none)" so that it can automatically add all necessary internal variables to the "shared clause" or that it only reports errors for variables which are not part of system header files. I don't know how many macros or variables will cause such an error. If their number is small, the compiler can maintain a small table with these names. Otherwise it may be a little bit more complicated. Furthermore I don't know if their might be a reason to have a private copy of an internal variable (although I cannot see any reason for such a thing, because an application program shouldn't know about internal variables or how system macros expand to internal variables). I would be happy, if it would be possible to write operating system independend code if I use standards (C11, OpenMP, pthreads, ...) and that the compiler would solve all operating system dependend problems if I only use standardized constructs. Perhaps somebody knows, if it is possible to fulfill my wish in an upcoming release of gcc. Kind regards Siegmar