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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:55:06+00:00 2026-06-08T20:55:06+00:00

I have written a library and I use that library in a program. I

  • 0

I have written a library and I use that library in a program. I often make a change in the program code, run tests with asserts turned on and then if the tests pass I run a benchmark with asserts turned off to measure the performance impact of the change I just made. I also want to turn the asserts on in my library for the tests and to turn them off in the library for the benchmark. So I frequently need to switch the assert setting simultaneously in the program and the library.

Matching the assert settings (NDEBUG) for the library and the program (that uses the library) must not be manual because getting it wrong means undefined behavior as there are asserts in the headers (conflicting definitions causes undefined behavior) and indeed I get a crashing program with GCC when I build an assert-off program with an assert-on library. I haven’t been able to find out what the standard way to do this is. I’m considering having my library build system install two binaries (and possibly headers that complain if they are included with the wrong assert setting (NDEBUG)) named libfoo-1.0 and libfoo-assert-1.0 or something like that.

What is the best way to match the assert setting between libraries and programs in such a way that switching the assert setting in both at the same time is easy, fast and not error prone?

  • 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-08T20:55:08+00:00Added an answer on June 8, 2026 at 8:55 pm

    Normally, build systems are set up to do different builds (e.g. debug/release, mutli/single threaded) anyway. The resultant libraries and executables are either placed in different directories or have different names to distinguish them. This is no different.

    If you feel you need additional build types for assert/noassert, then just add this additional build type. The only question is the naming convention and what is done by default if no particular build type is specified.

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

Sidebar

Related Questions

i have written a library with some classes that make use of qt object
I have a library written in C that I would like to use in
I'm trying to use some library code written in scala from a java program.
I have written a static library to re-use some code between iOS projects, let's
I have a common comms library that i have written to communicate with our
In physics library written in C# I have the following code: (in ContactManager.cs) public
I have a date picker library written for MooTools that I want to port
I have written a custom dialog (form) that I can use in a C#
I have a program written in C that has to input and output JSON
I have written a program that runs on Linux and uses sigevent and timer_create

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.