public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Importing a variable from a DLL
@ 1999-08-25 15:38 James Stern
  1999-08-25 23:29 ` Mumit Khan
  1999-08-31 23:49 ` James Stern
  0 siblings, 2 replies; 16+ messages in thread
From: James Stern @ 1999-08-25 15:38 UTC (permalink / raw)
  To: cygwin

The last time I posted to this list, I was asking a
question about a mysterious symbol,
_size_of_stack_reserve__, that gdb mentioned when my
program crashed.

Mumit Khan explained that this simply meant the code
had a bug elsewhere.  I looked and sure enough, I
found an extern variable that the DLL defines and the
main executable (main.exe) uses.

Declaring the variable __declspec (dllimport) in the
appropriate source file solved that.  But then I reran
the program and encountered the same problem with
another variable.

So I hunted for documentation on dllimport.  I found
only a few lines in full-man/info/* but more in the
MSVC documentation.

As I understand it, the situtation is this:  Suppose
that source file s1.cc used in main.exe references
extern variable v1 from the DLL.  Then s1.cc has to
declare v1 as __declspec (dllimport).  If s2.cc
through s20.cc also use v1, they must do likewise.

If this is true, I'll have to change about 140
declarations in the legacy application I'm porting. 
Each will need a macro, M, that expands to either
__declspec (dllimport) or to nothing.

These declarations appear in header files so I'll also
have to properly define M in every source file that
includes one of these headers.

Is there an easier way to do this?  For example, is
there a way to specify at link time that a variable is
imported?

I realize that the application has too many extern
variables but it's legacy and not mine to rewrite.

I also realize that fixups of this nature are harder
to do for variables than for functions but I thought I
should doublecheck anyway.

Thank you.
===
-- 
Opinions expressed above are not necessarily my employer's.
James M. Stern
ITG Inc.  Culver City, CA (213) 270-7955
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

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

end of thread, other threads:[~1999-08-31 23:49 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-25 15:38 Importing a variable from a DLL James Stern
1999-08-25 23:29 ` Mumit Khan
1999-08-26  3:33   ` Re[2]: " Paul Sokolovsky
1999-08-26  6:41     ` Mumit Khan
1999-08-26  8:05       ` Re[4]: " Paul Sokolovsky
1999-08-26 23:10         ` Mumit Khan
1999-08-27  8:00           ` Re[6]: " Paul Sokolovsky
1999-08-27  8:17             ` Mumit Khan
1999-08-31 23:49               ` Mumit Khan
1999-08-31 23:49             ` Paul Sokolovsky
1999-08-31 23:49           ` Re[4]: " Mumit Khan
1999-08-31 23:49         ` Paul Sokolovsky
1999-08-31 23:49       ` Re[2]: " Mumit Khan
1999-08-31 23:49     ` Paul Sokolovsky
1999-08-31 23:49   ` Mumit Khan
1999-08-31 23:49 ` James Stern

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).