WCRT C runtime library with source

Started by Pelle, September 20, 2004, 12:47:55 PM

Previous topic - Next topic

Pelle

WCRT is a small C runtime library for Visual C++, which implements parts of its functionality through calls to the Win32API. It is meant as a replacement for the Visual C runtime library (libc.lib) for small projects. Source included.

Version 1.12 has just been released. Works with Pelles C from v1.08.

http://www.ibsensoftware.com

Pelle
/Pelle

RJP Computing

How would a person use this in PellesC IDE? Sorry a newbie question. :wink:

Pelle

I have attached a project file for Pelles C - can at least be used as a starting point. Requires MASM, which can be found here: http://www.masm32.com/

(Check Project Options, Macros tab, AS macro, in case the path needs to be changed).

Pelle
/Pelle

RJP Computing

Hi Pelles,

Thanks but I think you didn't attach it to the forum. Is it on the main website?

Pelle

I didn't notice that. Sorry. Wrong file extension - not accepted. We try again...

Pelle
/Pelle


RJP Computing

I am sorry if I am repeating this topic again. I did look at you project file example but it appears to be how to actually compile the wcrt. So I have another "thick-headed" question for you. How do I use the wcrt.lib when creating a new program. I want to utilize the wcrt but I don't know how to tell poide to use this crt and not your default.

Jibz

Here is what I did to build a first test application:
[list=1]
  • Open/create a project
  • From the menu, select Project->Project Options ...
  • Under the Linker tab, add wcrt.lib with path under Library and object files
  • Under the Macros tab, add -I<path to wcrt include dir> at the end of the CCFLAGS macro
  • Click OK
  • Try building your project :)
    [/list:o]
    As an example, my CCFLAGS for the project were:
    -W1 -Ot -Gd -Tx86-coff -Ic:\wcrt\include
    and the libraries listed under the Linker tab were:
    kernel32.lib advapi32.lib delayimp.lib c:\wcrt\lib\wcrt.lib
    Hope this helps :).

RJP Computing

Yes. That did it.

I do get this warning.
QuotePOLINK: warning: Multiple '.rdata' sections found with different attributes (0x40000040 and 0xc0000040).
But it still runs just fine. What does this warning mean?
Thanks

EDIT: You can just drop the 'wcrt.lib' file in the PellesC 'Lib' directory and add this
#pragma comment(lib,"wcrt.lib")to the top of your code and it works great. This way if you want to switch back and forth between PellesC standard crt and the WCRT you can.

Jibz

As far as I know, the warning comes from a difference in the flags on the section containing C initializers between Visual C++ and Pelles C.

VC++ puts them in a section with read/write access (0xC0000040), whereas Pelles C puts them in the read-only section (0x40000040). Also it appears that Pelles C is merging them with the .rdata section, where VC++ merges them with the .data section.

However I do not know the details of Pelles C, so perhaps Pelle could shed some further light on this?

At any rate, it should not produce any problems other than the warning message when linking :).

Pelle

Jibz is absolutely correct.

Function pointers from #pragma startup/exit (or equivalent) are stored in a section called .CRT, which is merged with the .rdata section (read-only data) by POLINK. Microsoft merge .CRT with the .data section (read-write data). Not really sure why - might be a C++ thing. I should probably change this...

Pelle
/Pelle