Reputation:
I have disabled CRT, however I wish to use some of the run-time functions like strtok, strcmpy, strcpy and so on but I do not want the entire CRT running could someone tell me how I can use those functions without running CRT and enabling all CRT function.
I only want few CRT functions, could someone assist me?
Kind Regards,
Rohan Vijjhalwar
Upvotes: 2
Views: 221
Reputation: 13690
You need a kind of C run-time library, as you already told us with the wish for strcmp & Co. If you think you would get any benefit in creating smaller binaries or less dependencies to DLLs you can use any tiny-CRT.
For the use in a boot loader I wrote my own library with just the functions I needed. E.g. you can code the function strcpy
as:
// choose const for arguments where necessary.
char* strcpy(char *dst, char *src)
{
char* dest = dst;
// copy char by char until '\0' is found.
while ( *dest++ = *src++ )
{
}
return dst;
}
If you have a function like strtok
that isn't stateless, you have to initialize the state. So you will have to initialize your tiny CRT.
If you fear you can't write it entirely by your own search for someone else who did it for you, e.g. at Code Project or µCLib
Upvotes: 5