iferr warn_unused_result missed
-
After "successfully" converting plugins to R20 on Windows I took all source files to build the plugins on macOS, resulting in one error after the other where Xcode 9.2 reports:
ignoring return value of function declared with 'warn_unused_result' attribute
In the meantime I am familiar seeing this message and know it is because I simply implemented and maxon::BaseArray
Append
orErase
orResize
, or aCopyFrom
... or something related, without checking on the return value of the function.
Visual Studio already complained while I was converting the source code to R20 and compiling now and then. So, I knew it was related to adding someiferr
or similar.Visual Studio didn't complain any further, but apparently Xcode goes a little further and brings up a lot of code still containing append/erase/... which doesn't use any iferr.
As such, I was wondering what makes Xcode find these while Visual Studio missed them?
Except for differences between the Visual Studiosln
versus Xcodexcodeproj
theprojectdefinition.txt
are identical, since the same file is used for both platforms.It's not a big deal, but just a hassle since I have to convert the source code to R20 on Windows, then basically do the same again on macOS.
-
Hi @C4DS, unfortunately, it's not my main domain so I will ask you to wait until 7th January, where my other colleagues would be able to confirm what I say.
In Windows and Mac Os we do not use the same compiler, and the Mac OS one is more restrictive than the windows one.
So you either have to add theiferr
or iferr_ignore to remember why you didn't want to check the return state.Cheers,
Maxime. -
Replying to this topic to bring it back onto the radar, just in case more recent information could be added. As I still, now and then, encounter this problem when porting plugin updates to macOS.
-
Hello,
there is not much to add here. Visual Studio and Xcode are just two different programs. They use two different C++ compilers. Each compiler interprets (and supports) the C++ standard a little bit differently.
So Visual Studio 2015 does not pay attention to warn_unused_result while Xcode does. If in doubt, always compile on both platforms and make sure there are no warnings on any of these platforms.
You don't need to write different code for different platforms. You just have to write correct code and Xcode simply performs better checks.
General information on error handling can be found in the documentation: Error Handling.
best wishes,
Sebastian -
@s_bach said in iferr warn_unused_result missed:
You don't need to write different code for different platforms. You just have to write correct code and Xcode simply performs better checks.
I am not implying to writing different code per platform. That's the whole point I am trying to make here.
All I want is to write correct code, and let the compiler help me in the process, by notifying me where I left out required checks. Unfortunately, Visual Studio doesn't really help me here.
But developing on macOS is not an option, it's only used for building the final plugin.
Since I want to keep source code identical between macOS and Windows versions of the plugin, I need to adjust code on macOS to get it compiled, and port back these changes to the source code made with Visual Studio. (Source control is done on the Windows development machine, which doesn't always like a mixture of source code files from Windows and macOS)
I had hoped the preprocessing via the stylechecks could be used to streamline the issues brought up by the compiler. But, apparently, I am misinterpreting its purpose.
... If in doubt, always compile on both platforms and make sure there are no warnings
Well, that's exactly the reason for my query. I am starting to feel sorry for bringing it up.
-
Hello,
the Source Processor only checks for coding style violations and creates auxiliary code. It cannot check for valid C++ syntax (because C++ is quite an complex language).
Coming back to the issue of return values, only the compiler can check that at compile time. And, yes, unfortunately Visual Studio and Xcode behave differently.
best wishes,
Sebastian