tsoding / something

Finally something
MIT License
53 stars 11 forks source link

__MINGW32__ and addsuffix #335

Closed BillKek closed 3 years ago

BillKek commented 3 years ago

MINGW32 switch not needed. OS automatically defined in windows. addsuffix ".EXE" is for windows apps.

Tested on mingw64_i686 with msys2. Tested on debian.

kolumb commented 3 years ago

Initially there was check like this: https://github.com/tsoding/something/pull/154#discussion_r491973117 There should be MINGW32 macro. But when I compile from cmd there's no such macro. And when I try to compile from MSYS2 shell, my pkg-config can't find sdl2.pc. And pacman installs it in such location that that I couldn't specify it even manually, because it's path starts from C: drive. But maybe I'm doing something wrong... It's interesting what's your which pkg-config and echo $PKG_CONFIG_PATH on Windows MSYS2 shell.

BillKek commented 3 years ago

which pkg-config gives /usr/bin/pkg-config. echo $PKG_CONFIG_PATH gives /usr/lib/pkgconfig:/usr/share/pkgconfig:/lib/pkgconfig. echo $OS gives Windows_NT. echo $__MINGW32__ gives empty.

I compile from cmd with PATH=C:\msys64\mingw32\bin for 32bits version by mingw32-make. Also i compile from cmd with PATH=C:\msys64\mingw64\bin for 64bits version with success.

pacman installation for 32 bit version is pacman -S git mingw-w64-i686-toolchain mingw32/mingw-w64-i686-SDL2 mingw32/mingw-w64-i686-SDL2_mixer mingw32/mingw-w64-i686-SDL2_image mingw32/mingw-w64-i686-SDL2_ttf mingw32/mingw-w64-i686-SDL2_net mingw32/mingw-w64-i686-cmake make. Perhaps there was something else.

__MINGW32__ is compile-time pre-defined compiler macro automatically added by g++.

I did a test insert in source code:

#ifdef __MINGW32__
#warning __MINGW32__AVAIL
#endif
#ifdef __MINGW64__
#warning __MINGW64__AVAIL
#endif

Warning MINGW32 is raised in compile log in any case. Warning MINGW64 is raised in compile log when mingw64 path used.

kolumb commented 3 years ago

Thank you for detailed answer! Oh, in source code I have it too. For some reason I thought that it should work in Makefile. Facepalm That explains everything. So it's impossible to get compiler type in Makefile without executing shell command and stuff.

rexim commented 3 years ago

@kolumb @BillKek so, do I merge this PR or not? :D

kolumb commented 3 years ago

Yes :)

rexim commented 3 years ago

@BillKek looks good to me and @kolumb! :+1: Thank you for your contribution!