Code Monkey home page Code Monkey logo

Comments (9)

sharkdp avatar sharkdp commented on May 24, 2024 1

Not sure if there's currently a way to set a flag to enable or disable dbg depending on whether or not it's a debug build

There is no flag or mechanism to do this.

I'm trying to follow a similar philosophy as the Rust team did with their dbg!(…) macro.

Quoting from https://doc.rust-lang.org/std/macro.dbg.html

The dbg! macro works exactly the same in release builds. This is useful when debugging issues that only occur in release builds or when debugging in release mode is significantly faster.

Note that the macro is intended as a debugging tool and therefore you should avoid having uses of it in version control for longer periods.

This is why the dbg(…) macro does not disable itself in non-DEBUG builds.

That being said, I think I would be okay with adding a compile flag to disable the macro completely.

from dbg-macro.

sharkdp avatar sharkdp commented on May 24, 2024 1

I have hadded a DBG_MACRO_DISABLE compile time flag that can be used to disable the macro.

If disabled, the macro can still be used in expressions since we define it to be dbg(x) = x.

from dbg-macro.

alexzanderr avatar alexzanderr commented on May 24, 2024 1

woooow. ups. sorry. didnt know i was commenting on cpp repo.
i had this problem in rust and google sugested this repo and i clicked fast without looking.

from dbg-macro.

fgallegosalido avatar fgallegosalido commented on May 24, 2024

That's okay. Anyway, you should add something to the the macro when it is disabled, because a lot of "-Wunused-value" warnings appear in g++ and clang++, but that's different issue

from dbg-macro.

 avatar commented on May 24, 2024

@fgallegosalido I have prepared CI for AppleClang, GCC and MSVC. We will see about those warnings.

from dbg-macro.

sharkdp avatar sharkdp commented on May 24, 2024

Anyway, you should add something to the the macro when it is disabled, because a lot of "-Wunused-value" warnings appear in g++ and clang++

Good point. Would you like to open a new issue for that?

from dbg-macro.

fgallegosalido avatar fgallegosalido commented on May 24, 2024

Okay, I'm opening it now

from dbg-macro.

alexzanderr avatar alexzanderr commented on May 24, 2024

i tried to run a mini project that has dbg!(), but it doesnt work

command is:

DBG_MACRO_DISABLE=1 cargo run -q -p ldebug
# also tried this
DBG_MACRO_DISABLE=true cargo run -q -p ldebug

program is:

fn main() {
    let x = 123;
    dbg!(x);
}

output

❱  DBG_MACRO_DISABLE=1 cargo run -q -p ldebug
[crates/ldebug/src/main.rs:25] x = 123

How am I supposed to run cargo run with this flag DBG_MACRO_DISABLE ?

from dbg-macro.

Jackojc avatar Jackojc commented on May 24, 2024

I think you're mixing this project up with the Rust macro of the same name (I believe this project was inspired by it). https://doc.rust-lang.org/std/macro.dbg.html

from dbg-macro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.