Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Message-ID: <19990825224804.16894.rocketmail@web1405.mail.yahoo.com> Date: Wed, 25 Aug 1999 15:48:04 -0700 (PDT) From: James Stern Reply-To: stern AT itginc DOT com Subject: Importing a variable from a DLL To: cygwin AT sourceware DOT cygnus DOT com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 AT sourceware DOT cygnus DOT com