public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* direct.h + pthreads
@ 2002-05-28  7:17 Sven Sandberg
  2002-05-28  7:54 ` egor duda
  0 siblings, 1 reply; 4+ messages in thread
From: Sven Sandberg @ 2002-05-28  7:17 UTC (permalink / raw)
  To: cygwin

Hello,
I'm trying to compile a program that #includes <direct.h> and links with
pthreads, and keep running into problems:

 1. It appears that all programs linked with pthreads crash even before
invoking WinMain() if you compile with the -mno-cygwin flag. So I have
to link without it, right?
My command line is now:
   gcc -Wall -o tmp tmp.c -lpthread

 2. direct.h seems to be in the include path only if -mno-cygwin is
specified (why?), so I have to add -I/usr/include/mingw to the command
line.
My command line is now:
   gcc -I/usr/include/mingw -Wall -o tmp tmp.c

 3. My program also accesses errno. After I added -I/usr/include/mingw
to the command line, it gives undefined references to errno. For some
reason which I don't understand, this goes away if I add -I/usr/include
before -I/usr/include/mingw. (Is this normal?)
My command line is now:
   gcc -I/usr/include -I/usr/include/mingw -Wall -o tmp tmp.c

 4. My program also #includes <stdio.h>. With -I/usr/include, I get
several errors like this:
   /usr/include/stdio.h:162: parse error before `__gnuc_va_list'
   /usr/include/stdio.h:163: parse error before `__gnuc_va_list'
   /usr/include/stdio.h:164: parse error before `__gnuc_va_list'
   etc.
__VALIST expands to __gnuc_va_list, and as far as grep can see,
__gnuc_va_list is not defined in any header file on my disk. Sure, I can
do '#define __gnuc_va_list va_list', but this is hardly the way it's
intended to be done? (Plus, my program is really a library and it
doesn't seem nice to users to do this.)

Am I doing something wrong? Is there a better way to both #include
<direct.h> and use pthreads?

I apologize for the length of the following, but the FAQ says it has to
be included:

============ begin output from cygcheck -s -v -r ============

Cygnus Win95/NT Configuration Diagnostics
Current System Time: Tue May 28 01:30:21 2002

Windows 98 SE Ver 4.10 Build 2222 

Path:	C:\cygwin\usr\local\bin
	C:\cygwin\bin
	C:\cygwin\bin
	c:\DJGPP\BIN
	c:\WINDOWS
	c:\WINDOWS\COMMAND
	c:\
	c:\BATFILES
	c:\TOOLS
	c:\WINDOWS\COMMAND
	.
	c:\DEV-CPP\BIN

SysDir: C:\WINDOWS\SYSTEM
WinDir: C:\WINDOWS

HOME = `C:\cygwin\home\N.N.'
MAKE_MODE = `unix'
PWD = `c:/aldjvu'
USER = `N.N.'

ALLEGRO_USE_CYGWIN = `1'
CMDLINE = `bash --login -i'
COMSPEC = `C:\WINDOWS\COMMAND.COM'
DIRCMD = `/ogne'
DJGPP = `c:\djgpp\djgpp.env'
MINGDIR = `/usr/local'
OLDPWD = `c:/lib/djvulibre-3.5.5'
PROMPT = `$p$g'
PS1 = `\[\033]0;\w\007
\033[32m\]\u@\h \[\033[33m\w\033[0m\]
$ '
SHLVL = `1'
TEMP = `c:\WINDOWS\TEMP'
TERM = `cygwin'
TMP = `c:\WINDOWS\TEMP'
WINBOOTDIR = `C:\WINDOWS'
WINDIR = `C:\WINDOWS'
_ = `/usr/bin/cygcheck'

HKEY_CURRENT_USER\Software\Cygnus Solutions
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2
  (default) = `/cygdrive'
  cygdrive flags = 0x00000022
HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\Program Options
HKEY_LOCAL_MACHINE\Software\Cygnus Solutions
HKEY_LOCAL_MACHINE\Software\Cygnus Solutions\Cygwin
HKEY_LOCAL_MACHINE\Software\Cygnus Solutions\Cygwin\mounts v2
HKEY_LOCAL_MACHINE\Software\Cygnus Solutions\Cygwin\mounts v2\/
  (default) = `C:/cygwin'
  flags = 0x0000000a
HKEY_LOCAL_MACHINE\Software\Cygnus Solutions\Cygwin\mounts v2\/usr/bin
  (default) = `C:/cygwin/bin'
  flags = 0x0000000a
HKEY_LOCAL_MACHINE\Software\Cygnus Solutions\Cygwin\mounts v2\/usr/lib
  (default) = `C:/cygwin/lib'
  flags = 0x0000000a
HKEY_LOCAL_MACHINE\Software\Cygnus Solutions\Cygwin\Program Options

a:  fd           N/A    N/A                    
c:  hd  FAT32  10252Mb  78% CP    UN           INFILTRATÖR
d:  cd           N/A    N/A                    
e:  cd           N/A    N/A                    

.              /cygdrive  user    binmode,noumount
C:/cygwin      /          system  binmode
C:/cygwin/bin  /usr/bin   system  binmode
C:/cygwin/lib  /usr/lib   system  binmode

Found: C:\cygwin\bin\bash.exe
Found: c:\DJGPP\BIN\bash.exe
Warning: C:\cygwin\bin\bash.exe hides c:\DJGPP\BIN\bash.exe
Found: C:\cygwin\bin\cat.exe
Found: c:\DJGPP\BIN\cat.exe
Warning: C:\cygwin\bin\cat.exe hides c:\DJGPP\BIN\cat.exe
Found: C:\cygwin\bin\cpp.exe
Found: c:\DJGPP\BIN\cpp.exe
Warning: C:\cygwin\bin\cpp.exe hides c:\DJGPP\BIN\cpp.exe
Found: c:\DEV-CPP\BIN\cpp.exe
Warning: C:\cygwin\bin\cpp.exe hides c:\DEV-CPP\BIN\cpp.exe
Found: C:\cygwin\bin\find.exe
Found: c:\DJGPP\BIN\find.exe
Warning: C:\cygwin\bin\find.exe hides c:\DJGPP\BIN\find.exe
Found: c:\WINDOWS\COMMAND\find.exe
Warning: C:\cygwin\bin\find.exe hides c:\WINDOWS\COMMAND\find.exe
Found: C:\cygwin\bin\gcc.exe
Found: c:\DJGPP\BIN\gcc.exe
Warning: C:\cygwin\bin\gcc.exe hides c:\DJGPP\BIN\gcc.exe
Found: c:\DEV-CPP\BIN\gcc.exe
Warning: C:\cygwin\bin\gcc.exe hides c:\DEV-CPP\BIN\gcc.exe
Found: C:\cygwin\bin\gdb.exe
Found: c:\DJGPP\BIN\gdb.exe
Warning: C:\cygwin\bin\gdb.exe hides c:\DJGPP\BIN\gdb.exe
Found: C:\cygwin\bin\ld.exe
Found: c:\DJGPP\BIN\ld.exe
Warning: C:\cygwin\bin\ld.exe hides c:\DJGPP\BIN\ld.exe
Found: c:\DEV-CPP\BIN\ld.exe
Warning: C:\cygwin\bin\ld.exe hides c:\DEV-CPP\BIN\ld.exe
Found: C:\cygwin\bin\ls.exe
Found: c:\DJGPP\BIN\ls.exe
Warning: C:\cygwin\bin\ls.exe hides c:\DJGPP\BIN\ls.exe
Found: C:\cygwin\bin\make.exe
Found: c:\DJGPP\BIN\make.exe
Warning: C:\cygwin\bin\make.exe hides c:\DJGPP\BIN\make.exe
Found: c:\DEV-CPP\BIN\make.exe
Warning: C:\cygwin\bin\make.exe hides c:\DEV-CPP\BIN\make.exe
Found: C:\cygwin\bin\sh.exe
Found: c:\DJGPP\BIN\sh.exe
Warning: C:\cygwin\bin\sh.exe hides c:\DJGPP\BIN\sh.exe

  119k 2002/05/26 C:\WINDOWS\SYSTEM\cygjpeg6b.dll - os=4.0 img=1.0
sys=4.0
                  "cygjpeg6b.dll" v0.0 ts=2001/6/6 6:27
  720k 2002/05/26 C:\WINDOWS\SYSTEM\cygwin1.dll - os=4.0 img=1.0 sys=4.0
                  "cygwin1.dll" v0.0 ts=2001/12/8 23:02
    Cygwin DLL version info:
        DLL version: 1.3.6
        DLL epoch: 19
        DLL bad signal mask: 19005
        DLL old termios: 5
        DLL malloc env: 28
        API major: 0
        API minor: 47
        Shared data: 3
        DLL identifier: cygwin1
        Mount registry: 2
        Cygnus registry name: Cygnus Solutions
        Cygwin registry name: Cygwin
        Program options name: Program Options
        Cygwin mount registry name: mounts v2
        Cygdrive flags: cygdrive flags
        Cygdrive prefix: cygdrive prefix
        Cygdrive default prefix: 
        Build date: Sat Dec 8 17:02:30 EST 2001
        CVS tag: cygwin-1-3-6-6
        Shared id: cygwin1S3

   56k 2000/12/03 C:\cygwin\bin\cygbz21.0.dll - os=4.0 img=1.0 sys=4.0
                  "cygbz21.0.dll" v0.0 ts=2000/11/21 0:53
   99k 2001/11/20 C:\cygwin\bin\cygcurl-2.dll - os=4.0 img=1.0 sys=4.0
                  "cygcurl-2.dll" v0.0 ts=2001/11/20 17:45
  390k 2000/12/05 C:\cygwin\bin\cygtcl80.dll - os=4.0 img=1.0 sys=4.0
                  "cygtcl80.dll" v0.0 ts=2000/11/26 2:39
    5k 2000/12/05 C:\cygwin\bin\cygtclpip80.dll - os=4.0 img=1.0 sys=4.0
   10k 2000/12/05 C:\cygwin\bin\cygtclreg80.dll - os=4.0 img=1.0 sys=4.0
                  "cygtclreg80.dll" v0.0 ts=2000/11/26 2:39
   81k 2000/12/05 C:\cygwin\bin\cygitcl30.dll - os=4.0 img=1.0 sys=4.0
                  "cygitcl30.dll" v0.0 ts=2000/11/26 2:43
   35k 2000/12/05 C:\cygwin\bin\cygitk30.dll - os=4.0 img=1.0 sys=4.0
                  "cygitk30.dll" v0.0 ts=2000/11/26 2:43
  623k 2000/12/05 C:\cygwin\bin\cygtk80.dll - os=4.0 img=1.0 sys=4.0
                  "cygtk80.dll" v0.0 ts=2000/11/26 2:43
   18k 2000/10/23 C:\cygwin\bin\cyggdbm.dll - os=4.0 img=1.0 sys=4.0
                  "cyggdbm.dll" v0.0 ts=2000/10/23 4:26
   21k 2001/06/20 C:\cygwin\bin\cygintl.dll - os=4.0 img=1.0 sys=4.0
                  "cygintl.dll" v0.0 ts=2001/6/20 19:09
   45k 2001/07/04 C:\cygwin\bin\cygjbig1.dll - os=4.0 img=1.0 sys=4.0
                  "cygjbig1.dll" v0.0 ts=2001/7/4 5:25
  119k 2001/06/06 C:\cygwin\bin\cygjpeg6b.dll - os=4.0 img=1.0 sys=4.0
                  "cygjpeg6b.dll" v0.0 ts=2001/6/6 6:27
   22k 2001/12/13 C:\cygwin\bin\cygintl-1.dll - os=4.0 img=1.0 sys=4.0
                  "cygintl-1.dll" v0.0 ts=2001/12/13 10:28
   45k 2001/04/25 C:\cygwin\bin\cygform5.dll - os=4.0 img=1.0 sys=4.0
                  "cygform5.dll" v0.0 ts=2001/4/25 7:28
   26k 2001/04/25 C:\cygwin\bin\cygmenu5.dll - os=4.0 img=1.0 sys=4.0
                  "cygmenu5.dll" v0.0 ts=2001/4/25 7:27
  156k 2001/04/25 C:\cygwin\bin\cygncurses++5.dll - os=4.0 img=1.0
sys=4.0
                  "cygncurses++5.dll" v0.0 ts=2001/4/25 7:29
  226k 2001/04/25 C:\cygwin\bin\cygncurses5.dll - os=4.0 img=1.0 sys=4.0
                  "cygncurses5.dll" v0.0 ts=2001/4/25 7:17
   15k 2001/04/25 C:\cygwin\bin\cygpanel5.dll - os=4.0 img=1.0 sys=4.0
                  "cygpanel5.dll" v0.0 ts=2001/4/25 7:27
   35k 2002/01/09 C:\cygwin\bin\cygform6.dll - os=4.0 img=1.0 sys=4.0
                  "cygform6.dll" v0.0 ts=2002/1/9 7:03
   20k 2002/01/09 C:\cygwin\bin\cygmenu6.dll - os=4.0 img=1.0 sys=4.0
                  "cygmenu6.dll" v0.0 ts=2002/1/9 7:03
  175k 2002/01/09 C:\cygwin\bin\cygncurses++6.dll - os=4.0 img=1.0
sys=4.0
                  "cygncurses++6.dll" v0.0 ts=2002/1/9 7:03
  202k 2002/01/09 C:\cygwin\bin\cygncurses6.dll - os=4.0 img=1.0 sys=4.0
                  "cygncurses6.dll" v0.0 ts=2002/1/9 7:03
   12k 2002/01/09 C:\cygwin\bin\cygpanel6.dll - os=4.0 img=1.0 sys=4.0
                  "cygpanel6.dll" v0.0 ts=2002/1/9 7:03
  163k 2001/05/06 C:\cygwin\bin\cygpng2.dll - os=4.0 img=1.0 sys=4.0
                  "cygpng2.dll" v0.0 ts=2001/5/6 6:05
   17k 2001/06/28 C:\cygwin\bin\cyghistory4.dll - os=4.0 img=1.0 sys=4.0
                  "cyghistory4.dll" v0.0 ts=2001/1/7 5:34
  108k 2001/06/28 C:\cygwin\bin\cygreadline4.dll - os=4.0 img=1.0
sys=4.0
                  "cygreadline4.dll" v0.0 ts=2001/1/7 5:34
   20k 2002/01/13 C:\cygwin\bin\cyghistory5.dll - os=4.0 img=1.0 sys=4.0
                  "cyghistory5.dll" v0.0 ts=2002/1/13 2:27
  121k 2002/01/13 C:\cygwin\bin\cygreadline5.dll - os=4.0 img=1.0
sys=4.0
                  "cygreadline5.dll" v0.0 ts=2002/1/13 2:27
  610k 2001/12/28 C:\cygwin\bin\cygxml2-2.dll - os=4.0 img=1.0 sys=4.0
                  "cygxml2-2.dll" v0.0 ts=2001/12/28 13:49
   73k 2001/12/28 C:\cygwin\bin\cygexslt-0.dll - os=4.0 img=1.0 sys=4.0
                  "cygexslt-0.dll" v0.0 ts=2001/12/28 12:50
  202k 2001/12/28 C:\cygwin\bin\cygxslt-1.dll - os=4.0 img=1.0 sys=4.0
                  "cygxslt-1.dll" v0.0 ts=2001/12/28 12:13
   22k 2001/12/28 C:\cygwin\bin\cygxsltbreakpoint-1.dll - os=4.0 img=1.0
sys=4.0
                  "cygxsltbreakpoint-1.dll" v0.0 ts=2001/12/28 12:50
  821k 2001/11/19 C:\cygwin\bin\cygcrypto.dll - os=4.0 img=1.0 sys=4.0
                  "cygcrypto.dll" v0.0 ts=2001/11/20 0:42
  231k 2001/11/19 C:\cygwin\bin\cygssl.dll - os=4.0 img=1.0 sys=4.0
                  "cygssl.dll" v0.0 ts=2001/11/20 0:42
   40k 2001/11/21 C:\cygwin\bin\cygpcre.dll - os=4.0 img=1.0 sys=4.0
                  "cygpcre.dll" v0.0 ts=2001/11/21 23:15
   39k 2001/11/21 C:\cygwin\bin\cygpcreposix.dll - os=4.0 img=1.0
sys=4.0
                  "cygpcreposix.dll" v0.0 ts=2001/11/21 23:15
   66k 2001/11/20 C:\cygwin\bin\cygregex.dll - os=4.0 img=1.0 sys=4.0
                  "cygregex.dll" v0.0 ts=2001/11/20 15:44
  245k 2001/06/12 C:\cygwin\bin\cygtiff3.dll - os=4.0 img=1.0 sys=4.0
                  "cygtiff3.dll" v0.0 ts=2001/6/12 19:25
   41k 2001/07/04 C:\cygwin\bin\cygXpm-noX4.dll - os=4.0 img=1.0 sys=4.0
                  "cygXpm-noX4.dll" v0.0 ts=2001/7/4 3:21
   45k 2001/07/04 C:\cygwin\bin\cygXpm-X4.dll - os=4.0 img=1.0 sys=4.0
                  "cygXpm-X4.dll" v0.0 ts=2000/11/20 3:45
   49k 2001/02/03 C:\cygwin\bin\cygz.dll - os=4.0 img=1.0 sys=4.0
                  "cygz.dll" v0.0 ts=2001/2/3 21:35
  720k 2001/12/08 C:\cygwin\bin\cygwin1.dll - os=4.0 img=1.0 sys=4.0
                  "cygwin1.dll" v0.0 ts=2001/12/8 23:02
    Cygwin DLL version info:
        DLL version: 1.3.6
        DLL epoch: 19
        DLL bad signal mask: 19005
        DLL old termios: 5
        DLL malloc env: 28
        API major: 0
        API minor: 47
        Shared data: 3
        DLL identifier: cygwin1
        Mount registry: 2
        Cygnus registry name: Cygnus Solutions
        Cygwin registry name: Cygwin
        Program options name: Program Options
        Cygwin mount registry name: mounts v2
        Cygdrive flags: cygdrive flags
        Cygdrive prefix: cygdrive prefix
        Cygdrive default prefix: 
        Build date: Sat Dec 8 17:02:30 EST 2001
        CVS tag: cygwin-1-3-6-6
        Shared id: cygwin1S3


Cygwin Package Information
Last downloaded files to: pÙt
Last downloaded files from: ð\x05‡

Package             Version             
ash                 20011018-1          
autoconf            2.52-5              
autoconf-devel      2.52-4              
autoconf-stable     2.13-4              
automake            1.5a-1              
automake-devel      1.5-5               
automake-stable     1.4p5-5             
bash                2.05a-2             
bc                  1.06-1              
binutils            20011002-1          
bison               1.28-1              
byacc               0.0                 
bzip2               1.0.1-6             
clear               1.0                 
compface            1.4-5               
cpio                2.4.2               
cron                3.0.1-5             
crypt               1.0-1               
ctags               5.0.1-1             
curl                7.9.1-2             
cvs                 1.11.0-1            
cygrunsrv           0.94-2              
cygutils            0.9.7-1             
cygwin              1.3.6-6             
dejagnu             20010117-1          
diff                0.0                 
ed                  0.2-1               
expect              20010117-1          
figlet              2.2-1               
file                3.37-1              
fileutils           4.1-1               
findutils           4.1                 
flex                2.5.4-1             
fortune             1.8-1               
gawk                3.0.4-1             
gcc                 2.95.3-5            
gdb                 20010428-1          
gdbm                1.8.0-3             
gettext             0.10.38-2           
ghostscript         6.51-1              
gperf               0.0                 
grep                2.4.2-1             
groff               1.17.2-1            
gzip                1.3.2-1             
indent              2.2.6-2             
inetutils           1.3.2-16            
irc                 20010101-1          
jbigkit             1.2-4               
jpeg                6b-4                
less                358-3               
libintl             0.10.38-3           
libintl1            0.10.40-1           
libncurses5         5.2-1               
libncurses6         5.2-8               
libpng              1.0.11-1            
libreadline4        4.1-2               
libreadline5        4.2a-1              
libxml2             2.4.12-1            
libxslt             1.0.9-1             
login               1.4-3               
lynx                2.8.4-1             
m4                  0.0                 
make                3.79.1-5            
man                 1.5g-2              
mingw-runtime       1.1-1               
mktemp              1.4-1               
mt                  2.0.1-1             
mutt                1.2.5i-5            
nano                1.0.6-1             
ncftp               3.0.2-2             
ncurses             5.2-8               
newlib-man          20001118-1          
opengl              1.1.0-5             
openssh             3.0.2p1-3           
openssl             0.9.6b-2            
patch               2.5-2               
pcre                3.7-1               
perl                5.6.1-2             
popt                1.6.1-1             
postgresql          7.1.2-3             
python              2.1.1-2             
readline            4.2a-1              
regex               4.4-2               
robots              2.0-1               
rsync               2.4.6-3             
rxvt                2.7.2-6             
sed                 3.02-1              
sh-utils            2.0-2               
sharutils           4.2.1-1             
shutdown            1.2-2               
squid               2.4-STABLE20010508  
ssmtp               2.38.7-3            
tar                 1.13.19-1           
tcltk               20001125-1          
tcsh                6.11.00-2           
termcap             20010825-1          
terminfo            5.2-1               
tetex-beta          20001218-1          
texinfo             4.0-5               
textutils           2.0.16-1            
tiff                3.5.6beta-2         
time                1.7-1               
units               1.77-1              
unzip               5.41-1              
vim                 6.0.93-1            
w32api              1.1-1               
which               1.5-1               
whois               4.5.17-1            
xpm-nox             4.1.0-1             
zip                 2.3-1               
zlib                1.1.3-6             

Use -h to see help about each section

============ end output from cygcheck -s -v -r ============

Thanks for any help,

-- 
Sven Sandberg    svsa1977@student.uu.se    home.student.uu.se/svsa1977

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: direct.h + pthreads
  2002-05-28  7:17 direct.h + pthreads Sven Sandberg
@ 2002-05-28  7:54 ` egor duda
  2002-05-29  2:27   ` Sven Sandberg
  0 siblings, 1 reply; 4+ messages in thread
From: egor duda @ 2002-05-28  7:54 UTC (permalink / raw)
  To: Sven Sandberg; +Cc: cygwin

Hi!

Tuesday, 28 May, 2002 Sven Sandberg svsa1977@student.uu.se wrote:

SS> I'm trying to compile a program that #includes <direct.h> and links with
SS> pthreads, and keep running into problems:

You're trying to mix two unmixable things. I'll try to explain what
-mno-cygwin flag does and hope it will help you answer all those
questions yourself.

When you compile a program with gcc, it is supposed to run in some
environment called "platform". This environment includes a processor
(intel x86, sparc, alpha, etc), operating system that runs on your
machine (windows, linux, solaris, etc.) and runtime libraries that are
not themselves part of OS, but which are needed by your program to
run.

Gcc binary that produces an executable for some platform is said
to be targeted at that platform. That is, gcc distributed with cygwin
is cygwin-targeted. The resulting binary is expected to run on x86
processor + win32 OS + cygwin1.dll runtime library. Actually, there
are other platforms based on win32 OSes, but with different runtime
libraries. One of them is MinGW -- a platform which uses Microsoft's
runtime libraries -- MSVCRT.DLL or CRTDLL.DLL. Of course, different
platforms have different APIs -- for instance, linux have aio_read()
function and cygwin haven't, cygwin have GetCurrentProcessId()
function and linux haven't. So, each platform have its own set of
header files and libraries that represent a set of APIs available on
this platform. It's important to understand that cygwin and mingw is
different platforms, even though they're both based on win32 OS. For
example, cygwin platform have fork() API which is not available on
MinGW.

Incidentally, gcc distributed with cygwin is actually multi-targeted --
it can produce binaries for two different platforms -- cygwin and
mingw. By default the resulting binary is supposed to be run on cygwin
platform, but if you add -mno-cygwin switch to command line, it switch
to MinGW target, i.e. produce a binary to be run on MinGW platform.
When switching to other target, compiler should also switch to the
headers and libraries appropriate for this target. When you install
cygwin, those headers and libraries are put to /usr/include/mingw and
/usr/lib/mingw directories, while cygwin headers and libraries are put
in /usr/include and /usr/lib.

One shouldn't mix headers and libraries for different platforms (just
like you can't build cygwin program using, say, linux header files).
So, when you #include something to your code or link some library to
your object files you should ask yourself first: "Are those header or
library files for the platform that i want my program to be run on?"
If the answer is "yes" then you can safely use a particular header or
library. Otherwise, you should try to find some analog or substitution
for them.

As for direct.h and libpthread.a files that you're using the problem
is exactly in that: The former is MinGW header, while libpthread.a is
a cygwin library. You can't mix them. Actually, you can't include
direct.h if you're building cygwin executable and you can't link with
cygwin version of libpthread.a if you're building mingw executable.

So you should either try to find mingw version of pthread library and
build mingw program, or find a way to replace the occurrences of
functions from direct.h in your code to some code that does the same,
but uses only APIs available on cygwin platform.

SS>  1. It appears that all programs linked with pthreads crash even before
SS> invoking WinMain() if you compile with the -mno-cygwin flag. So I have
SS> to link without it, right?
SS> My command line is now:
SS>    gcc -Wall -o tmp tmp.c -lpthread

SS>  2. direct.h seems to be in the include path only if -mno-cygwin is
SS> specified (why?), so I have to add -I/usr/include/mingw to the command
SS> line.
SS> My command line is now:
SS>    gcc -I/usr/include/mingw -Wall -o tmp tmp.c

SS>  3. My program also accesses errno. After I added -I/usr/include/mingw
SS> to the command line, it gives undefined references to errno. For some
SS> reason which I don't understand, this goes away if I add -I/usr/include
SS> before -I/usr/include/mingw. (Is this normal?)
SS> My command line is now:
SS>    gcc -I/usr/include -I/usr/include/mingw -Wall -o tmp tmp.c

SS>  4. My program also #includes <stdio.h>. With -I/usr/include, I get
SS> several errors like this:
SS>    /usr/include/stdio.h:162: parse error before `__gnuc_va_list'
SS>    /usr/include/stdio.h:163: parse error before `__gnuc_va_list'
SS>    /usr/include/stdio.h:164: parse error before `__gnuc_va_list'
SS>    etc.
SS> __VALIST expands to __gnuc_va_list, and as far as grep can see,
SS> __gnuc_va_list is not defined in any header file on my disk. Sure, I can
SS> do '#define __gnuc_va_list va_list', but this is hardly the way it's
SS> intended to be done? (Plus, my program is really a library and it
SS> doesn't seem nice to users to do this.)

SS> Am I doing something wrong? Is there a better way to both #include
SS> <direct.h> and use pthreads?

Egor.            mailto:deo@logos-m.ru ICQ 5165414 FidoNet 2:5020/496.19


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: direct.h + pthreads
  2002-05-28  7:54 ` egor duda
@ 2002-05-29  2:27   ` Sven Sandberg
  2002-05-29  2:52     ` Robert Collins
  0 siblings, 1 reply; 4+ messages in thread
From: Sven Sandberg @ 2002-05-29  2:27 UTC (permalink / raw)
  To: cygwin

egor duda wrote:
> You're trying to mix two unmixable things. I'll try to explain what
> -mno-cygwin flag does and hope it will help you answer all those
> questions yourself.

Thank you for explaining, that makes sense.

> One shouldn't mix headers and libraries for different platforms

You can actually mix dlls and programs compiled with MinGW32, Borland
C++ Builder, and MSVC freely if you do it correctly. Is it strictly
impossible to mix these with Cygwin, or just tricky? Is it possible if
I'm allowed to modify headers?

-- 
Sven Sandberg    svsa1977@student.uu.se    home.student.uu.se/svsa1977

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: direct.h + pthreads
  2002-05-29  2:27   ` Sven Sandberg
@ 2002-05-29  2:52     ` Robert Collins
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Collins @ 2002-05-29  2:52 UTC (permalink / raw)
  To: 'Sven Sandberg', cygwin



> -----Original Message-----
> From: cygwin-owner@cygwin.com 
> [mailto:cygwin-owner@cygwin.com] On Behalf Of Sven Sandberg
> Sent: Wednesday, 29 May 2002 8:43 AM
> To: cygwin@cygwin.com
> Subject: Re: direct.h + pthreads
> 
> 
> egor duda wrote:
> > You're trying to mix two unmixable things. I'll try to explain what
> > -mno-cygwin flag does and hope it will help you answer all those
> > questions yourself.
> 
> Thank you for explaining, that makes sense.
> 
> > One shouldn't mix headers and libraries for different platforms
> 
> You can actually mix dlls and programs compiled with MinGW32, Borland
> C++ Builder, and MSVC freely if you do it correctly. Is it strictly
> impossible to mix these with Cygwin, or just tricky? Is it possible if
> I'm allowed to modify headers?

You can only mix DLL's that follow the same rules for:
Structure alignment
C runtime
Exception handling

And do not contain C++. 

Libpthread.a is a cygwin1.dll alias. This means that you are trying to
break the C++ rule, the C runtime rule, the exception handling rule and
the Structure alignment rule all at once.

Rob


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-05-28 22:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-28  7:17 direct.h + pthreads Sven Sandberg
2002-05-28  7:54 ` egor duda
2002-05-29  2:27   ` Sven Sandberg
2002-05-29  2:52     ` Robert Collins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).