Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    iferr warn_unused_result missed

    Cinema 4D SDK
    3
    6
    1.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C4DSC
      C4DS
      last edited by

      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 or Erase or Resize, or a CopyFrom ... 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 some iferr 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 Studio sln versus Xcode xcodeproj the projectdefinition.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.

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        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 the iferr or iferr_ignore to remember why you didn't want to check the return state.

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 1
        • C4DSC
          C4DS
          last edited by

          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.

          1 Reply Last reply Reply Quote 1
          • S
            s_bach
            last edited by s_bach

            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

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            C4DSC 1 Reply Last reply Reply Quote 0
            • C4DSC
              C4DS @s_bach
              last edited by

              @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.

              1 Reply Last reply Reply Quote 0
              • S
                s_bach
                last edited by

                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

                MAXON SDK Specialist

                Development Blog, MAXON Registered Developer

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post