Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
define customized fluid_return_if_fail
unlike glib's g_return_if_fail, dont log to console if condition fails
- Loading branch information
Showing
1 changed file
with
9 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b1d0db7There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix breaks compilation with Visual Studio.
The macro fluid_return_if_fail() should be changed to:
#define fluid_return_if_fail(cond) if (!(cond)) return
Because fluid_return_val_if_fail(cond, ((void)(0))) expands a "return (void)0" and MSVC complains that a void function is returning a value.
b1d0db7There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the hint. I tested it with clang and gcc, both accept it. And IMO MSVC is wrong. I'm returning a value that I've casted to void. Thus I'm returning void. I admit it's an ugly and very nit-picky way of avoiding code duplications, but I dont see the problem.
Shouldnt it expand to "return ((void)(0))"? What version(s) of MSVC have you tried?
b1d0db7There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just compiled FluidSynth on Windows 10 64-bit with Visual Studio 2017 64-bit to test LADSPA on Windows and got the same warnings.
b1d0db7There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify: this doesn't seem to break the build, but just throws warnings all over the place. But there is probably a switch to turn warnings into errors, just like on Linux gcc...
b1d0db7There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's ugly and only saves three extra code lines, maybe it's not really worth it :-)
b1d0db7There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was curious, grabbed a VS2012 and compiled a simple demo prog. I didnt got a warning, probably used a too low warning level. But at least it compiled. The assembly output is also the same for both
returnandreturn ((void)0). I really think that in this case raising a warning is incorrect. Casting a value to void means discarding the value and in the end nothing is returned. Disabling this warning is not an option, so I'll be so kind and change this to a conventional boringreturn.