simavr icon indicating copy to clipboard operation
simavr copied to clipboard

Check if environment is MinGW and implement missing strsep()

Open Mihaylov93 opened this issue 4 years ago • 6 comments

Fix for #403

Some implementations of string.h might not come come with strsep() as its not standard.

Mihaylov93 avatar Oct 03 '20 14:10 Mihaylov93

I can´t guarantee that the different string.h implementations will have defines for their methods, hence this is not universal solution,

Closed until I find a proper solution.

Mihaylov93 avatar Oct 03 '20 14:10 Mihaylov93

FWIW, glibc does not define strsep, nor any other macro that would clearly imply that strsep() is implemented.

edgar-bonet avatar Oct 03 '20 16:10 edgar-bonet

Yes, my bad for not checking, usually libs come with the macros. Another possibility is to check for compiler.

#ifdef __clang__
/*code specific to clang compiler*/
#elif __GNUC__
/*code for GNU C compiler */
#elif _MSC_VER
/*usually has the version number in _MSC_VER*/
/*code specific to MSVC compiler*/
#elif __BORLANDC__
/*code specific to borland compilers*/
#elif __MINGW32__
/*code specific to mingw compilers*/
#endif

Mihaylov93 avatar Oct 04 '20 00:10 Mihaylov93

Do you guys have any objection about replacing #ifdef __MINGW32__ with #ifdef _WIN32 ? looks like clang will have the same issue https://github.com/llvm-mirror/libcxx/blob/master/include/string.h and probably MSVC too.

Mihaylov93 avatar Oct 05 '20 16:10 Mihaylov93

Quite frankly I don't think why we'd bother with "32" bits versions of M$ OSes.. isn't there something more posixy to use on windows these days, like that Linux Subsystem for Windows?

buserror avatar Oct 13 '20 18:10 buserror

The macros __MINGW32__ and _WIN32 are defined by compilers for 32-bit and 64-bit.

isn't there something more posixy to use on windows these days, like that Linux Subsystem for Windows?

Isn´t that MinGW?

Mihaylov93 avatar Oct 14 '20 23:10 Mihaylov93