[203] in Pthreads mailing list archive

home help back first fref pref prev next nref lref last post

Problems with -D_POSIX_SOURCE and -ansi flags

daemon@ATHENA.MIT.EDU (Yann Langlais)
Mon Nov 13 18:48:49 1995

From: Yann Langlais <ylanglais@houston.geoquest.slb.com>
To: pthreads@MIT.EDU
Date: Mon, 13 Nov 1995 17:19:59 -0600 (CST)


Hi again.

I've got some REAL difficulties trying to use the -D_POSIX_SOURCE
and the -ansi flags while compiling a prog using pthreads.

Configuration:
SunOS 4.1.3C
gcc2.7.0
pthreads-1.60_beta4_1

while compiling with no special flag, except -ggdb -fPIC and the 
include path for the pthread includes (wich is on my local disk),
no problem.
But I usually try to get a stricter compilation avoiding the 
non portable stuff with the flags:
-ansi -D_POSIX_SOURCE -Wall -pedantic

and then, it says:

889 felix p3 /home/langlais/dev/multithread
%gcc -ggdb -fPIC -ansi -D_POSIX_SOURCE -Wall -pedantic -ggdb -fPIC  -I/home/langlais/include tthread.c  
-o Tthread  -L/home/langlais/lib -lpthread -ldl -lm
In file included from tthread.c:2:
/home/langlais/include/stdio.h:332: syntax error before `int'
In file included from /home/langlais/include/pthread/machdep.h:8,
                 from /home/langlais/include/pthread.h:46,
                 from tthread.c:5:
/home/langlais/include/unistd.h:66: parse error before `sleep'
/home/langlais/include/unistd.h:66: warning: parameter names (without types) in function declaration
/home/langlais/include/unistd.h:66: ANSI C forbids data definition with no type or storage class
/home/langlais/include/unistd.h:72: parse error before `alarm'
/home/langlais/include/unistd.h:72: warning: parameter names (without types) in function declaration
/home/langlais/include/unistd.h:72: ANSI C forbids data definition with no type or storage class
890 felix p3 /home/langlais/dev/multithread
%                                                                               17:08:52 13/11/1995



The parse errors are due to:
__INLINE which is defined w/ exotic and gcc specific stuff (i.e. static inline or extern inline)
u_int    which is undefined.

if I remove the -ansi flag:
%gcc -ggdb -fPIC -D_POSIX_SOURCE -Wall -pedantic -ggdb -fPIC -I/home/langlais/include tthread.c 
-o Tthread -L/home/langlais/lib -lpthread -ldl -lm
In file included from tthread.c:2:
/home/langlais/include/stdio.h:332: warning: ANSI does not permit the keyword `inline'
In file included from /home/langlais/include/pthread/machdep.h:8,
                 from /home/langlais/include/pthread.h:46,
                 from tthread.c:5:
/home/langlais/include/unistd.h:66: parse error before `sleep'
/home/langlais/include/unistd.h:66: warning: parameter names (without types) in function declaration
/home/langlais/include/unistd.h:66: ANSI C forbids data definition with no type or storage class
/home/langlais/include/unistd.h:72: parse error before `alarm'
/home/langlais/include/unistd.h:72: warning: parameter names (without types) in function declaration
/home/langlais/include/unistd.h:72: ANSI C forbids data definition with no type or storage class

Still a problem of u_int definition.

And with -ansi but NO -D_POSIX_SOURCE:
891 felix p3 /home/langlais/dev/multithread
%gcc -ggdb -fPIC -ansi -Wall -pedantic -ggdb -fPIC -I/home/langlais/include tthread.c 
-o Tthread -L/home/langlais/lib -lpthread -ldl -lm
In file included from tthread.c:2:
/home/langlais/include/stdio.h:332: syntax error before `int'

(due to __INLINE)

which is better, but still not ok.


I tried to play with the __GNUC__ and the __STDC__, but it only creates more problems
and I'm not that familiar with these kind of ``games''.


Has someone got a tip allow ANSI and POSIX enforcement using gcc on SunOS?

Thanks!


                 |     Yann LANGLAIS    |          l.                    
             langlais@houston.GeoQuest.slb.com     lOO.      
                 |     o  o             |          lOOl}    
                 |      __              |          lOT]   
                 |     /  \             |          IOI   
                 |     \___|  o  /|     |          IOI   
             ____|\_______/|____/  \___/           lO
             \                                     lO    
      _       \           oOOO                     lI              Oo 
     /         |        .OOO'                   ob Oo             oOO 
    |         /       .OOO'        ollO.         OD`OOOOOOOOOOOOOOOO' 
     \_______/o o     OOOD          "OOOP        OO        ol. ol.
                        OOOo.                    oO'        `OP `OP
                        `"TOOOo.             oOOP     
                            `"TOOOo.      ooO'        
                                  `"SOOOP"'    


home help back first fref pref prev next nref lref last post