Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm 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 From: "Hannu E K Nevalainen (garbage mail)" To: Subject: RE: Linking VC++ DLL Date: Mon, 24 Mar 2003 15:49:03 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Importance: Normal > From: cygwin-owner AT cygwin DOT com [mailto:cygwin-owner AT cygwin DOT com]On Behalf --8<-- > extern "C" __declspec(dllexport) int hello() > { > printf("Hello World!\n"); > return 345; > } --8<-- > int main() > { > printf("What is this? %d\n", hello()); > } > > All I get in return is (under Cygwin): > What is this? 345 > > 345 demonstrates that the function was called and correctly returned but > why is it that the printf statement in the function hello() went missing? > I have tried to run other VC compiled program but had no problem in > getting printf statements to work under the Cygwin environment. Would > appreciate if anyone can suggest what could be the possible > problem. Thanks! > > regards > Edward I believe this is close to off topic on the cygwin list. ;-) My guess is that stdin/stdout from main() isn't defined/visible for the functions inside your library. To illustrate the problem; Try this: --8<-- extern "C" __declspec(dllexport) int hello(FILE *of) { fprintf(of,"Hello World!\n"); return 345; } --8<-- int main() { printf("What is this? %d\n", hello(stdout)); } --8<-- ... which MIGHT work. Expect something like: Hello World! What is this? 345 as output. You may have a problem here: I believe you have to think about which version of printf() you wish to have available in your library and/or program. Your library might contain *a copy of printf()*, I'm not sure it will be sufficient for all situations. Especially as it seems as you're using two different compilers/environments to compile your library and program. If so; IMHO there is great potential for serious malfunction. /Hannu E K Nevalainen, Mariefred, Sweden --END OF MESSAGE-- -- 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/