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 Update on Monday, May 27th 2025

Structured Exception handling in Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.3k 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.
  • C Offline
    C Offline
    Cobra91151
    wrote on 27 Feb 2018, 10:24 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.

    J 1 Reply Last reply 27 Feb 2018, 11:36
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 27 Feb 2018, 11:34 last edited by
      #2

      Use standard try and catch.

      (Z(:^

      C 1 Reply Last reply 27 Feb 2018, 11:37
      1
      • C Cobra91151
        27 Feb 2018, 10:24

        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.

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 27 Feb 2018, 11:36 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

        C 1 Reply Last reply 27 Feb 2018, 11:38
        3
        • S sierdzio
          27 Feb 2018, 11:34

          Use standard try and catch.

          C Offline
          C Offline
          Cobra91151
          wrote on 27 Feb 2018, 11:37 last edited by
          #4

          @sierdzio

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

          1 Reply Last reply
          0
          • J jsulm
            27 Feb 2018, 11:36

            @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

            C Offline
            C Offline
            Cobra91151
            wrote on 27 Feb 2018, 11:38 last edited by
            #5

            @jsulm

            Ok. I will check it. Thanks.

            1 Reply Last reply
            0

            1/5

            27 Feb 2018, 10:24

            • Login

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