Pelles C forum

C language => Tips & tricks => Topic started by: TimoVJL on December 17, 2017, 12:06:11 am

Title: crtmin
Post by: TimoVJL on December 17, 2017, 12:06:11 am
When someone want to make program without normal crt.lib.
Examples to make a minimal crtmin.lib nocrt.lib.
Code: [Select]
@REM crtmin.cmd
polib crt.lib -extract:_chkstk.obj -extract:_ftoll.obj -extract:_llshl.obj -extract:_llshr.obj -extract:_llmul.obj -extract:_lldiv.obj
polib.exe _chkstk.obj _llshl.obj _llshr.obj _ftoll.obj _lldiv.obj _llmul.obj -out:nocrt.lib
pause
Code: [Select]
@REM crtmin64.cmd
polib crt64.lib -extract:_chkstk.obj
polib _chkstk.obj -out:nocrt64.lib
pause
EDIT 2019-04-24: renamed example libs
Title: Re: crtmin
Post by: bitcoin on April 18, 2019, 04:27:53 pm
What differences between normal and minimal crt?
Title: Re: crtmin
Post by: TimoVJL on April 19, 2019, 01:30:20 am
crtmin.lib usually have a compiler specific routines, that do not belong to C standard.
nocrt.lib for my examples using Pelles C 9
x86
Code: [Select]
@SET crtlib=crt.lib
polib %crtlib% -extract:_chkstk.obj -extract:_llshl.obj -extract:_llshr.obj -extract:_lldiv.obj -extract:_llmul.obj -extract:_ullmod.obj  -extract:_ulldiv.obj  -extract:_crtabort.obj  -extract:_ftoll.obj  -extract:_fvalues.obj  -extract:_values.obj  -extract:seh1.obj  -extract:seh2.obj
polib -out:nocrt.lib *.obj
x64
Code: [Select]
@SET crtlib=crt64.lib
polib %crtlib% -extract:_chkstk.obj  -extract:_ehandler.obj polib -extract:_crtabort.obj  -extract:_fvalues.obj  -extract:_values.obj
polib -out:nocrt64.lib *.obj
EDIT 2019-04-24: renamed example libs
Title: Re: crtmin
Post by: Vortex on April 23, 2019, 11:56:34 am
Hi bitcoin,

Another purpose of making a minimalist C run-time library is not to depend on external sources like msvcrt.dll
Title: Re: crtmin
Post by: jj2007 on April 24, 2019, 08:34:56 am
I am not a fan of the CRT, and don't use it in my libraries. However, if you are programming in Windows, then Msvcrt.dll is present on your machine. It's not an "external" thing that the user has to buy and install, it's simply there waiting to be used.

IMHO rolling your own is justified only if it improves your stuff: Can you reduce code size with an own routine? No, because a call to an existing function costs 6 bytes. Which leaves exactly one reason to reinvent the wheel: speed 8)
Title: Re: crtmin
Post by: TimoVJL on April 24, 2019, 09:00:17 am
OK. A confusing name.
Maybe the NoCRT.lib is a better name for compiler specific support routines.