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

Compilation fails on VS2017 #69

Closed
Paimon2 opened this issue Mar 9, 2019 · 3 comments
Closed

Compilation fails on VS2017 #69

Paimon2 opened this issue Mar 9, 2019 · 3 comments

Comments

@Paimon2
Copy link

Paimon2 commented Mar 9, 2019

Compilation on Visual Studio 2017 fails due to the following errors:

E0546 transfer of control bypasses initialization of: variable (result) declared at line 384

and

C2362 initialization of 'result' is skipped by 'goto end'

Changing lines 374-384 in nfd_win.cpp from:
if ( !SUCCEEDED(coResult))
{
fileOpenDialog = NULL;
NFDi_SetError("Could not initialize COM.");
goto end;
}
// Create dialog
HRESULT result = ::CoCreateInstance(::CLSID_FileOpenDialog, NULL,
CLSCTX_ALL, ::IID_IFileOpenDialog,
reinterpret_cast<void**>(&fileOpenDialog) );

to:

HRESULT result = NULL;
if ( !SUCCEEDED(coResult))
{
fileOpenDialog = NULL;
NFDi_SetError("Could not initialize COM.");
goto end;
}
// Create dialog
result = ::CoCreateInstance(::CLSID_FileOpenDialog, NULL,
CLSCTX_ALL, ::IID_IFileOpenDialog,
reinterpret_cast<void**>(&fileOpenDialog) );

seems to fix the issue and the dialogs work without any issues.

@MrSapps
Copy link
Contributor

MrSapps commented Mar 22, 2019

You could probably also switch to using that small CComPtr object I added too

Edit: Because it would remove the goto's manual frees and thus also remove the warning/error.

@mlabbe
Copy link
Owner

mlabbe commented Sep 28, 2019

This doesn't happen on fresh checkout on vs2017 on the latest code as of the time of your posting. You must be doing something else you're not describing.

@mlabbe mlabbe closed this as completed Sep 28, 2019
@Paimon2
Copy link
Author

Paimon2 commented Sep 28, 2019

Perhaps that would be the case. I don't use Windows anymore so I am unable to reproduce the issue on an updated version on VS.

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

3 participants