X-Spam-Check-By: sourceware.org Message-ID: <46425FB7.8C763D51@dessent.net> Date: Wed, 09 May 2007 16:56:39 -0700 From: Brian Dessent X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Please Help!! Calling Socket function in a dll file (that is created using cygwin library), by a Microsoft Visual C++ program resulting in infinite loop References: <507150040705021415r750600a6oc6e24b339bf57143 AT mail DOT gmail DOT com> <463909F9 DOT 6B33B9C7 AT dessent DOT net> <507150040705081919i1cbf7194y9672fc6a1b1601a2 AT mail DOT gmail DOT com> <46416B9E DOT 71C3D2C3 AT dessent DOT net> <507150040705091556y3f4842fawb084d359a83c4606 AT mail DOT gmail DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Reply-To: cygwin AT cygwin DOT com Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com kalasad mailu wrote: > I used the socket.h file provided by cygwin(/usr/include/cygwin/.) and > wrote a program to create socket, made this a dll file and used this > dll in VC++. > > I assume using of the socket.h( form cygwin) did all the conversion > form the linux system calls to the windows system calls and made my > socket program work. Please correct me if my understanding is wrong. A header file does not implement anything. It contains no code at all (except in the case of C++ or inlined functions.) It only describes an interface that is actually implemented in a library. In the case of Cygwin, the standard C library is implemented by cygwin1.dll, along with many POSIX functions. > Now I want to try the same process for simple c++ functions like > "cout". I don't find any cygwin header files like iostream.h or > stream.h in the cygwin directory. cout is part of the C++ standard library (STL) and is implemented by libstdc++ which is part of gcc. > When I created this stand alone program. > > #include > > int main () { > std::cout << "Hello World\n"; > return 0; > } > > I guess this picked the header file from > "cygwin\lib\gcc\i686-pc-cygwin\3.4.4\include\c++\" (a gcc header file) > > Is there no iostream header file by cygwin (/usr/include/cygwin)? First of all, stop looking in /usr/include/cygwin for things, and stop worrying about which directory header files are in. That has no bearing on what library implements a specific function, as all headers for all installed libraries are in /usr/include. Some of these headers are provided by Cygwin. The ones in the "cygwin" subdirectory are only for Cygwin-specific things, but this is only a small fraction of the functionality provided by Cygwin. For example, all of the stadard C library functions (such as stdio.h, stdlib.h, io.h, stdint.h, and on and on) are all implemented by Cygwin, i.e. cygwin1.dll, and are in /usr/include. And many other libraries as well, such as zlib, gettext, libintl, and so on. So, stop confusing a header file with the library that implements the code and realize that the location a header file resides on disk has no relationship at all to the implementation. > I am running into header file conflict when I also include both cygwin > header files and the gcc header files. How to solve the conflict? No, there's no conflict. Gcc implements some libraries of its own, and Cygwin provides most of the standard C library. > Is it possible to make a dll that uses the functions defined by the > gcc header file(***not the cygwin header file i.e. present in > (/usr/include/cygwin)***) and use it in the MSVC++? Stop thinking of things by directory! Look at the headers in the cygwin package (cygcheck -l cygwin). This represents everything implemented by cygwin1.dll. See that there are many things outside of /usr/include/cygwin. Now look at the libraries provided by gcc for the C++ runtime (cygcheck -l gcc-g++). See that gcc implements most of the C++ runtime functionality. There are all designed to perfectly coexist, there is no problem with using both in a given program or DLL. As to using something in MSVC, first of all libstdc++ is gcc specific, so there is no way to use it at the source level with anything else. YOu can link to it at the binary level, i.e. call code written by g++ from MSVC, but only if the interface is 'extern "C"', because the two compilers have different C++ ABIs which cannot coexist. > If including the header file from gcc works then why is cygwin > providing separate header files(like stdio.h, stdlib.h and etc in > /usr/include/cygwin)? Different headers provide different things. /usr/include/stdio.h provides the standard C library interface. /usr/include/sys/stdio.h provides low level implementation details. You do not normally write #include , as it is included by other headers automatically. Stop focusing on the location of things, and think of it as an interface. When you use #include you are using a certain interface; the details of how it is implemented are not your concern. stdio.h could include /usr/include/foo/bar/baz.h if it wanted to. Brian -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/