Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't compile on Windows under MinGW (TDM-gcc) #129

Closed
cstamford opened this issue Mar 10, 2015 · 1 comment
Closed

Doesn't compile on Windows under MinGW (TDM-gcc) #129

cstamford opened this issue Mar 10, 2015 · 1 comment

Comments

@cstamford
Copy link
Contributor

Compilation fails on Windows when using the TDM-gcc (http://tdm-gcc.tdragon.net/) MinGW distribution (and possibly others, though I did not test) with the flag -std=c++14 due to the following error:

error: 'swprintf' was not declared in this scope

When removing that flag (or undefining STRICT_ANSI) compilation then fails with this error:

C:\CppFormat\format.cc: In instantiation of 'static int fmt::internal::CharTraits<wchar_t>::format_float(wchar_t*, std::size_t, const wchar_t*, unsigned int, int, T) [with T = double; std::size_t = unsigned int]':
C:\CppFormat\format.cc:1159:48:   required from here
C:\CppFormat\format.cc:391:45: error: invalid conversion from 'std::size_t {aka unsigned int}' to 'const wchar_t*' [-fpermissive]
         swprintf(buffer, size, format, value) :
                                             ^
In file included from C:\MinGW/lib/gcc/mingw32/4.9.2/include/c++/cstdio:42:0,
                 from C:\CppFormat\format.h:36,
                 from C:\CppFormat\format.cc:28:
C:\MinGW/include/stdio.h:579:37: note: initializing argument 2 of 'int swprintf(wchar_t*, const wchar_t*, ...)'
 _CRTIMP int __cdecl __MINGW_NOTHROW swprintf (wchar_t*, const wchar_t*, ...);

This is because swprintf is defined without the maxlen parameter in stdio.h as such:

/* These differ from the ISO C prototypes, which have a maxlen parameter (like snprintf).  */
#ifndef __STRICT_ANSI__
_CRTIMP int __cdecl __MINGW_NOTHROW swprintf (wchar_t*, const wchar_t*, ...);
_CRTIMP int __cdecl __MINGW_NOTHROW vswprintf (wchar_t*, const wchar_t*, __VALIST);
#endif
@cstamford cstamford changed the title Doesn't compile on Windows under MinGW Doesn't compile on Windows under MinGW (TDM-gcc) Mar 10, 2015
@vitaut
Copy link
Contributor

vitaut commented Mar 10, 2015

Thanks for catching this and providing a fix.

@vitaut vitaut closed this as completed Mar 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants