mlabbe / nativefiledialog

A tiny, neat C library that portably invokes native file open and save dialogs.
zlib License
1.77k stars 209 forks source link

Fix MinGW requiring fpermissive to compile #63

Closed ncruces closed 5 years ago

ncruces commented 5 years ago

This is the error I get otherwise:

../../src/nfd_win.cpp: In function 'nfdresult_t NFD_OpenDialog(const nfdchar_t*, const nfdchar_t*, nfdchar_t**)':
../../src/nfd_win.cpp:448:1: error: jump to label 'end' [-fpermissive]
 end:
 ^~~
../../src/nfd_win.cpp:379:14: note:   from here
         goto end;
              ^~~
../../src/nfd_win.cpp:383:13: note:   crosses initialization of 'HRESULT result'
     HRESULT result = ::CoCreateInstance(::CLSID_FileOpenDialog, NULL,
             ^~~~~~
ncruces commented 5 years ago

Change was tested with MinGW-w64 6.0.0, both 32 and 64-bit (GCC 8.1.0).

I don't have Visual Studio to test with, but change appears innocuous, and it seems to compile on AppVeyor?

Thanks!

mlabbe commented 5 years ago

Thanks for the patch but due to a subsequent refactoring it conflicts. I fixed it in 081cce2903f25e5e9e2727cbdc1b38fb4eed342e in the devel branch if you'd like to try and see if it works for you. More approvals means I can push it to master quicker.

ncruces commented 4 years ago

@mlabbe, I can confirm the fix.

However I had a painful experience trying to compile this with MinGW, following your instructions.

I had the following error messages:

==== Building nfd (release_x64) ====
process_begin: CreateProcess(NULL, echo Linking nfd, ...) failed.
make (e=2): The system cannot find the file specified.
make[1]: *** [nfd.make:135: ../lib/Release/x64/nfd.lib] Error 2
make: *** [Makefile:49: nfd] Error 2

Eventually fixed them by doing:

make SHELL=cmd CC=g++

Where SHELL is the important bit. Maybe you want to add that to your instructions?

mlabbe commented 4 years ago

Yes, I only tested in using cmd. That looks like a good addition to me. For reference, which shell were you using which caused it to fail?

ncruces commented 4 years ago

I'm not sure, to be honest. I'm using a cmd window, echo %shell% comes up empty. Is mingw32-make assuming some kind of MSYS environment?

Any way, that fixed it on my install of Mingw-w64.

ncruces commented 4 years ago

Actually it seems (see here) that you can't have any sh/bash in your path, otherwise make will try to use that (and your makefiles won't like it).

I had git installed and in my path, and that brings MSYS bash with it.

I don't know how common that is, but setting SHELL fixes it, I assume with little downside?