delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/03/24/09:50:37

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
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)" <garbage_collector AT telia DOT com>
To: <cygwin AT cygwin DOT com>
Subject: RE: Linking VC++ DLL
Date: Mon, 24 Mar 2003 15:49:03 +0100
Message-ID: <NGBBLLIAMFLGJEOAJCCEEEBMCNAA.garbage_collector@telia.com>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
In-Reply-To: <Pine.GSO.4.21.0303241837570.9209-100000@sf0.comp.nus.edu.sg>
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019