ned14 / status-code

Proposed SG14 status_code for the C++ standard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Newest MSVC can't compile avoid_stdio_include::write

interj opened this issue · comments

Apparently new MSVC (19.23 or 14.23 or whatever out-of-whack version there is) hates extern "C" write too.

extern "C" ptrdiff_t write(int, const void *, size_t);

Dropping C linkage from signature solves the issue, but I don't know if it won't break something else, since this is a POSIX function. Also, write is deprecated in Windows CRT, so this might break yet again in the future.

I updated the single header include which was stale, sorry.

I'm on MSVC 19.23.28107 and not seeing any issue with what you mention above. Can you try trunk?

I don't think this is related - this particular problem originated in outcome-experimental header and these changes where already present in ned14/outcome@8a8431e

There are several problems with that declaration. First, Microsoft's UCRT only has a 32-bit version (int write(int, const void *, unsigned) so the compiler complains about mismatched parameter types. Second, the missing __declspec(dllimport) results in a redeclaration compilation error when it encounters the real declaration when linking against a dynamic runtime. But adding it prevents linking the runtime statically. This could be solved using the same /alternatename workaround as elsewhere.

Lets try the usual MSVC linker hack then. Thanks for the suggestion.