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 8937595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:26:33+00:00 2026-06-15T10:26:33+00:00

Possible Duplicate: Can I redefine a C++ macro then define it back? I have

  • 0

Possible Duplicate:
Can I redefine a C++ macro then define it back?

I have an application that calls a function from a third party SDK lots of times along the app lifetime. This third party function checks for some errors with its _3RDPARTY_ASSERT (which is a wrapper around _ASSERT).

My problem is that in one of these calls, I sometimes expect an error (and handle it afterwards). I would like to disable the assert in this case, as it’s quite annoying while debugging, but keep it in all the other cases.

I have tried to handle it with pragma push_macro/pop_macro but I haven’t found a way.
Is this possible?

I have the source of 3rdParty.cpp but would prefer not to touch it.

This would be a simplified version of the code:

mine.cpp:

#include "3rdparty.h"

HRESULT MyMethod(...)
{
    HRESULT hr;
    hr = _3rdParty(...);
    if (SUCCEEDED(hr))
        hr = _3rdParty(...);
    if (SUCCEEDED(hr))
        hr = _3rdParty(...);
    ...    
    if (SUCCEEDED(hr))
        hr = _3rdParty(...); // This call shouldn't throw the assertion, as I expect it to fail sometimes!
    if (FAILED(hr))
        doSomething();
    else
        doSomethingElse();
    ...
    if (SUCCEEDED(hr))
       hr = _3rdParty(...);
    return hr;    
}

3rdParty.cpp:

...
#define _3RDPARTY_ASSERT (_ASSERT)
...
HRESULT _3rdParty(...)
{
    HRESULT hr;
    hr = SomeFunction();
    _3RDPARTY_ASSERT(SUCCEEDED(hr));
    return hr;
}
  • 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-06-15T10:26:34+00:00Added an answer on June 15, 2026 at 10:26 am

    The problem here is that unless it is inlined, the function will be tokenized and compiled a single time. This means it doesn’t matter if the macro is defined or not when you call the function, only when it is compiling the function itself.

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

Sidebar

Related Questions

Possible Duplicate: Can you have multiple $(document).ready(function() sections? Is it OK to have multiple
Possible Duplicate: Can we post on Google plus from android application? According to this
Possible Duplicate: Can a recursive function be inline? I think that recursive function defined
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Can I run from command line program created by Eclipse? I am
Possible Duplicate: Can I scroll a ScrollView programmatically in Android? I have a chat
Possible Duplicate: Can Read-Only Properties be Implemented in Pure JavaScript? I have an Object
Possible Duplicate: Can I embed a custom font in an iPhone application? Hi I
Possible Duplicate: Can I change all my links to just //? I've learnt that
Possible Duplicate: Can someone Explain this jQuery code? I have posted this before, but

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.