help-gengetopt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[help-gengetopt] VC++ 7.1- build with /MD flag


From: vc
Subject: [help-gengetopt] VC++ 7.1- build with /MD flag
Date: Wed, 14 May 2003 20:46:01 +0200

Hi all,

I'm working on Win2k, and I'm using VC++ 7.1 beta (VS .NET).

I have to port a Linux application on Windows and as this app is using the
gengetopt lib
I also have to port this one. From the gengetopt lib just 3 files are used:
getopt.c
getopt1.c
getopt.h
as these are enough for our needs.

For Windows, I created a project that includes these 3 files I set the
"Runtime Library"
flag on /MT (meaning link statically the CRT-C runtime lib) and the library
and the sample that we have that are using the lib were working ok.

Then I've changed the /MT flag to /MD flag (meaning link dynamically the
CRT) and in the test
I got the following error:
error C2664: 'getopt_long' : cannot convert parameter 1 from 'int' to 'int
*(__cdecl *)(void)'

It sounded stupid, but then I research a little and I found in
D:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\stdlib.h
the following code:
#if defined(_DLL) && defined(_M_IX86)

#define __argc (*__p___argc()) /* count of cmd line args */

#define __argv (*__p___argv()) /* pointer to table of cmd line args */

#define __wargv (*__p___wargv()) /* pointer to table of wide cmd line args
*/

#define _environ (*__p__environ()) /* pointer to environment table */

#else
...

When the /MD flag is defined, this means that the _DLL flag is defined, that
is why
it is going through this code and that is why I got that error.

The solution is easy: I can modify in the getopt.h file:
from __argc to _argc
from __argv to _argv

But my questions are:
1) If I'm making the above changes (renaming), don't I break anything? Maybe
it was used on purpose the __argc and __argv names?
2) Is there another way to build the sources on Windows using the VC++
that doesn't go into this trouble? I mean: am I the only one that got into
this problem?

Thanks a lot in advance,
Viv




reply via email to

[Prev in Thread] Current Thread [Next in Thread]