delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/10/31/08:41:51

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT sourceware DOT cygnus DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
From: "Colin Peters" <colinp AT ma DOT kcom DOT ne DOT jp>
To: "GNU-win32" <cygwin AT sourceware DOT cygnus DOT com>
Cc: "Khan Mumit" <khan AT xraylith DOT wisc DOT edu>, <uf657 AT victoria DOT tc DOT ca>
Subject: RE: mingw32 DLL getting main args?
Date: Sun, 31 Oct 1999 22:39:29 +0900
Message-ID: <LOBBLDDPANDBNCLMBAGPKEDICCAA.colinp@ma.kcom.ne.jp>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Importance: Normal
In-Reply-To: <199910291722.MAA18548@pluto.xraylith.wisc.edu>

Hello Mumit and Danny, I think this one is my fault, but I also think
I have (had?) an excuse. :)

The reason DLLs call getmainargs to parse the command line list
is so that they can provide the MS-like _argc and _argv variables for
access by functions within the DLL. Check init.c, which is #included
(yuck) in dllcrt1.c. If you like you can remove the declarations from
stdlib.h and work up a DLL version of init.c to remove the dependency
of your DLL on the C run-time library. (I suspect this hasn't changed
in Mumit's version, I must admit I only checked my source.)

I suppose the other reason I didn't worry much about this was that I
wasn't expecting people to write much DLL code without calling any
C library functions.

Mumit Khan [mailto:khan AT nanotech DOT wisc DOT edu] wrote:
> Danny Sinclair <uf657 AT victoria DOT tc DOT ca> writes:
> > Why does a DLL, made with Mumit's mingw32 2.95 release, need to call
> > msvcrt.dll's __getmainargs?
> >
> > When the DLLMainCRTStartup function receives DLL_PROCESS_ATTACH it calls
> > _mingw32_init_mainargs, which then calls __getmainargs. I don't want my
> > DLL to be dynamicly linked to msvcrt.dll, but it is because of this. Why
> > does a DLL need to parse the command line?
> >
>
> Good point. I don't know why it's done that way (it was there when I first
> used it). MSVC does not seem to do this, but DLLs created with MSVC are
> linked dynamically to MSVCRT.DLL (if you have /MD). I'll do some checking,
> and remove the getmainargs if it's not needed.

Cheers,
Colin.


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


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