Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3355422
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:23:38+00:00 2026-05-18T02:23:38+00:00

I’m trying to disable exceptions completely in Visual Studio 2010, and to ensure that

  • 0

I’m trying to disable exceptions completely in Visual Studio 2010, and to ensure that exception handling is disabled I have the following test:

class CompilerFlagsTestExceptionConstructor
{
public:
 CompilerFlagsTestExceptionConstructor() { throw std::exception("Exceptions Enabled"); }
 ~CompilerFlagsTestExceptionConstructor() { }
};

class CompilerFlagsTests : public CPPUNIT_NS::TestFixture
{
 CPPUNIT_TEST_SUITE( CompilerFlagsTests );
  CPPUNIT_TEST( Test_NoExceptions );
 CPPUNIT_TEST_SUITE_END();
public:
 void Test_NoExceptions()
 {
  try
  {
   CompilerFlagsTestExceptionConstructor object;
  }
  catch(std::exception)
  {
   assert(!"Exceptions are enabled");
  }
 }
};

I have checked in the property pages that exception handling is disabled, and I’ve also disabled RTTI in all my projects. I have tried setting /EH to negative as well as omitting it from the command line.

Every time I run this test, it fails and it properly throws an exception

The reason I want to disable exception handling is because the target software is written for a target architecture that doesn’t natively support exception handling and causes massive code bloat to accommodate the stack unwinding. The target architecture also has a maximum size of executable, so disabling exceptions shrinks code and also has a performance benefit. I want to disable exception handling on the windows version to ensure that the error handling to the target is working.

Am I doing something wrong? Is this test ever going to work? Is there some other way of forcing and testing that exceptions are disabled?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:23:38+00:00Added an answer on May 18, 2026 at 2:23 am

    I’m not sure your test makes sense. What should the behavior be if exceptions are disabled? throw just becomes a no op? That’s what the test suggests the behavior is.

    I would expect for usefully disabling exceptions throw should be a compile error, or alternatively throwing with exceptions disabled should immediately terminate the process.

    But this is a digression. MSVC will emit a call to _CxxThrowException for the throw syntax. If we define our own version of this we can make it dance to our song:

    #include <windows.h>
    #include <stdio.h>
    
    extern "C"
    void __stdcall _CxxThrowException(void * pObject,
        _s__ThrowInfo const * pObjectInfo)
    {
    
      printf("Nope\n");
    }
    
    struct a
    { };
    
    int main()
    {
      try {
      throw a();
      } catch(const a&) {
        printf("Caught an exception\n");
      }
    }
    

    This program prints out

    Nope

    Of course this information is provided for purely entertainment purposes and with the context that you’re doing this to match up with the error handling logic. I hope for example, that you don’t intend to ship the windows version of the program to anyone like this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.