Creating named tempfiles

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 4 00:29:58 PST 2015


On Wednesday, February 04, 2015 00:13:21 Jonathan M Davis via Digitalmars-d wrote:
> On Wednesday, February 04, 2015 07:34:14 Kagamin via Digitalmars-d wrote:
> > Looks like a relatively new function, so I guess, snn simply
> > doesn't implement it.
>
> No. If I grep dmc's folder, snn.lib contains _wsopen. It doesn't contain
> _wsopen_s, which is what MS wants folks to use, but it does have _wsopen.
> However, when I try and use it, I get
>
> Error 42: Symbol Undefined __wsopen at 16
>
> As I understand it, snn.lib is already linked in for other stdio stuff, so I
> don't know why it can't find _wsopen. And adding pragma(lib, "snn.lib");
> doesn't help. So, I don't know what to do.

Oh, wait. Looking over io.h, whereas _wsopen is declared, I see two
problems. One, MS declared it as

int _wsopen(const wchar* filename, int oflag, int shflag, int pmode);

whereas dmc seems to have

int __CLIB _wsopen(const wchar_t *, int, int, ...);

So, for some reason, dmc made it variadic. And the second problem is that
dmc has that block of function declarations surrounded by

#ifdef __NT__
#ifndef __STDC__
// declarations
#endif
#endif

and it's quite possible that the declarations are being skipped entirely.
And since changing the D declaration for _wsopen to be variadic simply
changes the error message to

 Error 42: Symbol Undefined __wsopen at 12

that would imply that those declarations aren't actually enabled. And
without some version of _wsopen, I don't know how to get the code working
properly on Windows. Maybe the a version will work? But those are supposed
to be avoided like the plague as I understand it.

All in all, this is quite annoying.

- Jonathan M Davis



More information about the Digitalmars-d mailing list