Fedict / eid-mw

eID Middleware (main repository)
GNU Lesser General Public License v3.0
198 stars 79 forks source link

#177 check if libstdc++ is used on windows instead of MSVC std lib #179

Closed erikjanss closed 1 year ago

Frederikus commented 2 years ago

Hello, Sorry fort he late reply Could you adapt the change a little, so it doesn't impact other compilers? Problem is that we do not know which compilers are used in the field to compile our code, and that some (ICC, CLang,..) might use different std:lib implementations based on the platform they are running. As I'd prefer not to brake what might currently be used in the field, could you change it perhaps a little to something like

ifdef WIN32

#ifdef [mingw or gcc macro]
        out[i] = std::use_facet < std::ctype < wchar_t >
            >(locale).narrow(in[i], 'x');
#else
        out[i] = std::use_facet < std::ctype < wchar_t >
            >(locale).narrow(in[i]);
#endif

else

        // in the unix implementation of std::locale narrow needs 2 arguments
        // (the second is a default char, here the choice is random)
        out[i] = std::use_facet < std::ctype < wchar_t >
            >(locale).narrow(in[i], 'x');

endif

This logic might not yet be sound for all compilers, but it shouldn't brake anything for any currently used (compiler/platform/std::lib usage) combination

erikjanss commented 1 year ago

use of libstdc++ with or without gcc can be detected using _GLIBCXX_RELEASE

https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html

erikjanss commented 1 year ago

@Frederikus thank you for your revieuw, I understand the reasoning. The modified pr will leave the code unchanged if not compiling for windows. When compiling on windows the change will take effect only when compiling against the libstdc++ library.

Frederikus commented 1 year ago

@erikjanss Thank you for the changes and the pull request.