Subject: RE: MSVCRT/threads
From: [email-masked]

22 Oct 1998 13:54:16 -0700
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
To: [email-masked]

On Mon, 19 Oct 1998, Mumit Khan wrote:

>> >>But it still fails with EGCS. After reading the source for process.h
I've
>> >>added this line:
>> >> #define __MSVCRT__ //For EGCS
>> >
>> >
>> >Remove that line, the procedure I describe should do the equivalent for
>> >you...
>>
>> Thanks, it works :-).

>Be careful. As I had mentioned to you in my email, if you use certain
>routines out of the target libraries, your program will crash if they'
>re not recompiled for MSVCRT.

Thats correct. I tried compile a C++ program that uses iostream.
1. There is a linking problem with HUGE_VAL
2. The linker tries to link with 'lcrtdll' even if it is not mentioned at
all in the specs.
3. I put a HUGE_VAL in a dummy libcrtdll.a to eliminate problems 1, 2
4. Only then the program linked OK but crashed at runtime.

I think that the situation of a __MSVCRT__  #define in the mingw32 headers
is bad.
The headers should not remind __MSVCRT__ or any other macro that depends
on the actual runtime linked.

Instead mingw32 should add some functions in libmingw32.a to overcome the
problem.
It is clear that there will be two libmingw32.a files (for msvcrt, and for
crtdll).

Example:

The code (from errno.h)

     #ifdef    __MSVCRT__
     /* One of the MSVCRTxx libraries */
     extern int*    __imp__sys_nerr;
     #define   sys_nerr  (*__imp__sys_nerr)
     #else
     /* CRTDLL run time library */
     extern int*    __imp__sys_nerr_dll;
     #define sys_nerr    (*__imp__sys_nerr_dll)
     #endif

could be replaced with:

     extern int*         __mingw32_sys_nerr(void);
     #define sys_nerr    (*__mingw32_sys_nerr())

All the differences will be in the function __mingw32_sys_nerr(void).
A similar pattern for all other differences.

Gains:
* I can compile my code so that it will not depend on the runtime selected.
* All the libraries (except libmingw32.a) will not depend on the runtime
DLL.
* Distribution is much simpler. (no duplication of all the libs).

What do you think ?

Eyal.

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".