Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Including Throwing Exceptions classes to NOEXCEPT project
QtWS25 Last Chance

Including Throwing Exceptions classes to NOEXCEPT project

Scheduled Pinned Locked Moved Solved C++ Gurus
cryptoppexceptionsnoexceptc++
14 Posts 4 Posters 4.5k Views
  • 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.
  • VRoninV Offline
    VRoninV Offline
    VRonin
    wrote on last edited by
    #4

    From https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_exceptions.html:

    If you might have some code that throws, you shouldn't use -fno-exceptions. If you have some code that uses try or catch, you shouldn't use -fno-exceptions.

    So the answer is no

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
    ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    K 1 Reply Last reply
    4
    • VRoninV VRonin

      From https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_exceptions.html:

      If you might have some code that throws, you shouldn't use -fno-exceptions. If you have some code that uses try or catch, you shouldn't use -fno-exceptions.

      So the answer is no

      K Offline
      K Offline
      Kofr
      wrote on last edited by
      #5

      @VRonin thank you for your answer.

      1 Reply Last reply
      0
      • K Kofr

        I want to include classes to my noexcept project which throw exceptions (I say about cryptopp).
        After that my project can not be built.
        How to leave the project noexcept when continue using cryptopp with exceptions?
        What technics exist to make class noexcept? (hope there is any besides direct deleating throwing code in original classes)

        K Offline
        K Offline
        Konstantin Tokarev
        wrote on last edited by
        #6

        @Kofr You can build part of your project that uses throwing code without -fno-exceptions.

        Or just use different library that doesn't throw, like openssl or gcrypt.

        K 1 Reply Last reply
        2
        • K Kofr

          @Paul-Colby thank you for the answer.
          I compile with use qmake CONFIG += exceptions_off.
          This is same as gcc flag -fno-exceptions
          Any use of exceptions cause fail to build. I do not know what is the exact errors.
          I think it will not help at all if I catch all exceptions because I do not want to use exceptions mechanism at all.

          K Offline
          K Offline
          Konstantin Tokarev
          wrote on last edited by
          #7

          @Kofr For example of the exterme case, I'm building QtWebKit with disabled exceptions but one file enables them to catch possible std::bad_alloc from Qt:

          https://github.com/annulen/webkit/blob/qtwebkit-5.212/Source/WebCore/PlatformQt.cmake#L194

          In qmake it's impossible to set flags for one file, so you will need to split exception-enabled code into (static) library

          1 Reply Last reply
          1
          • K Konstantin Tokarev

            @Kofr You can build part of your project that uses throwing code without -fno-exceptions.

            Or just use different library that doesn't throw, like openssl or gcrypt.

            K Offline
            K Offline
            Kofr
            wrote on last edited by
            #8

            @Konstantin-Tokarev I still see the problem. If you build exception throwing code into .lib or .a there is still header which is not noexcept. Is it ok for the compiler to work with such header and lib or the problem is real?

            K 2 Replies Last reply
            0
            • K Kofr

              @Konstantin-Tokarev I still see the problem. If you build exception throwing code into .lib or .a there is still header which is not noexcept. Is it ok for the compiler to work with such header and lib or the problem is real?

              K Offline
              K Offline
              Konstantin Tokarev
              wrote on last edited by
              #9

              @Kofr Seems like you didn't understand problem yet. You need to separate catching code into the library, not only throwing.

              So you basically need a wrapper that will call trowing functions and catch all exceptions, then use this wrapper in noexcept code.

              K 1 Reply Last reply
              2
              • K Kofr

                @Konstantin-Tokarev I still see the problem. If you build exception throwing code into .lib or .a there is still header which is not noexcept. Is it ok for the compiler to work with such header and lib or the problem is real?

                K Offline
                K Offline
                Konstantin Tokarev
                wrote on last edited by
                #10

                (I hope you are not going to ignore errors from cryptographic library)

                1 Reply Last reply
                0
                • K Konstantin Tokarev

                  @Kofr Seems like you didn't understand problem yet. You need to separate catching code into the library, not only throwing.

                  So you basically need a wrapper that will call trowing functions and catch all exceptions, then use this wrapper in noexcept code.

                  K Offline
                  K Offline
                  Kofr
                  wrote on last edited by
                  #11

                  @Konstantin-Tokarev said in Including Throwing Exceptions classes to NOEXCEPT project:

                  sically need a wrapper that will call trowing functions and catch all exceptions, then use this wrapper in noexcept code.

                  thx, now I got the trick

                  K 1 Reply Last reply
                  0
                  • K Kofr

                    @Konstantin-Tokarev said in Including Throwing Exceptions classes to NOEXCEPT project:

                    sically need a wrapper that will call trowing functions and catch all exceptions, then use this wrapper in noexcept code.

                    thx, now I got the trick

                    K Offline
                    K Offline
                    Konstantin Tokarev
                    wrote on last edited by
                    #12

                    Also, I don't know if this trick works with MSVC, didn't try that yet

                    VRoninV 1 Reply Last reply
                    0
                    • K Konstantin Tokarev

                      Also, I don't know if this trick works with MSVC, didn't try that yet

                      VRoninV Offline
                      VRoninV Offline
                      VRonin
                      wrote on last edited by
                      #13

                      @Konstantin-Tokarev Visual Studio allows per-file compile flags so the trick should be redundant

                      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                      ~Napoleon Bonaparte

                      On a crusade to banish setIndexWidget() from the holy land of Qt

                      K 1 Reply Last reply
                      1
                      • VRoninV VRonin

                        @Konstantin-Tokarev Visual Studio allows per-file compile flags so the trick should be redundant

                        K Offline
                        K Offline
                        Konstantin Tokarev
                        wrote on last edited by
                        #14

                        @VRonin I don't doubt that Visual Studio can do this, my poins are

                        • qmake doesn't have native way to set source-specific flags, you need to create your own custom target with all gory details of building C++ file, so it's much easier to move it into library
                        • I don't know if mixing EH flags in the same binary is reliable with MSVC
                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved