Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Structured Exception handling in Qt
Forum Updated to NodeBB v4.3 + New Features

Structured Exception handling in Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.3k Views 1 Watching
  • 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.
  • Cobra91151C Offline
    Cobra91151C Offline
    Cobra91151
    wrote on last edited by
    #1

    Hi! I want to write some Structured Exception handling in the application to collect user feedback/or free resources safely.

    __try {
           // some test code
    }
    __except (EXCEPTION_EXECUTE_HANDLER) {
            qDebug() << "Exception";
    }
    

    It's working in Visual Studio, but in Qt I get the following error:

    error: C2712: Cannot use __try in functions that require object unwinding

    Any ideas how to fix it? Thanks.

    jsulmJ 1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Use standard try and catch.

      (Z(:^

      Cobra91151C 1 Reply Last reply
      1
      • Cobra91151C Cobra91151

        Hi! I want to write some Structured Exception handling in the application to collect user feedback/or free resources safely.

        __try {
               // some test code
        }
        __except (EXCEPTION_EXECUTE_HANDLER) {
                qDebug() << "Exception";
        }
        

        It's working in Visual Studio, but in Qt I get the following error:

        error: C2712: Cannot use __try in functions that require object unwinding

        Any ideas how to fix it? Thanks.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Cobra91151 It sin't related to Qt, Qt is a framework not a compiler.
        See here https://msdn.microsoft.com/en-us/library/xwtb73ad.aspx

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        Cobra91151C 1 Reply Last reply
        3
        • sierdzioS sierdzio

          Use standard try and catch.

          Cobra91151C Offline
          Cobra91151C Offline
          Cobra91151
          wrote on last edited by
          #4

          @sierdzio

          But try and catch only handles the C++ exceptions not Structured Exception.

          1 Reply Last reply
          0
          • jsulmJ jsulm

            @Cobra91151 It sin't related to Qt, Qt is a framework not a compiler.
            See here https://msdn.microsoft.com/en-us/library/xwtb73ad.aspx

            Cobra91151C Offline
            Cobra91151C Offline
            Cobra91151
            wrote on last edited by
            #5

            @jsulm

            Ok. I will check it. Thanks.

            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