How to change _wfopen_s for BCB? or any instead?
Thank for any comments,
Best regards,
James
In BCB there is _wfopen. Add stdio.h to use it.
FILE *fileHandle = _wfopen(filename, filemode);
You must understand that all these _s functions microsoft invented are
there just for better safety (so they say). All of them have name formed
like this : <existing_function>_s . It is safe for the test purporses to
replace _s functions with ones without _s with some minor changes in
paramteres. There is no need to ask every time you need to replace a
function. Just go to the MSDN and see the documentation for both version
of functions (_wfopen_s and _wfopen in this case) to know what needs to
be changed.
In BCB _wfopen_s could be quickly implemented like this :
#include <errno.h>
#include <stdio.h>
int __cdecl _wfopen_s( FILE **pFile,
const wchar_t *filename,
const wchar_t *mode ) {
*pFile = _wfopen(filename, mode);
return errno;
}
> You must understand that all these _s functions microsoft invented are
I think it should be possible to use the MSFT functions by linking
dynamically to their RTL. The functions have C linkage and are not
mangled, so it should be possible to use them by creating an import
library for one of the msvcrt*.dll
> You must understand that all these _s functions microsoft invented are
> there just for better safety (so they say).
I am clear.
MS change order of parameter, let me confuse...
Best regards,
James
Ms CRT library is not that transaparent for general use. It would take a
bit more work to make use of it in BCB.
A starting point would be here
http://www.hailstorm.net/papers/smallwin32.htm
http://www.microsoft.com/msj/archive/S569.aspx
But it still does not justifies all that work for only few functions
that can easily be replaced.
>
> Ms CRT library is not that transaparent for general use. It would take a
> bit more work to make use of it in BCB.
>
I think the links you gave do more than what's needed...