This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
RE: Linking VC++ DLL
- From: "Hannu E K Nevalainen (garbage mail)" <garbage_collector at telia dot com>
- To: <cygwin at cygwin dot com>
- Date: Mon, 24 Mar 2003 15:49:03 +0100
- Subject: RE: Linking VC++ DLL
> 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/