In .NET I would use System.Diagnostics.Trace…
What would I use in C or C++ ?
right now I have a macro defined:
diagnostics ON:
#define DIAG(A) { printf(A); }
debugging off:
#define DIAG(A) { if(FALSE) {}}
Is there a standard way?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
It depends on your environment. In Windows, I’d just use OutputDebugString. There’s more complicated and configurable ways, but I’ve never needed it myself.
Not sure if there’s a standard on *nix, though. The relatively few times I’ve written *nix C code, I use a
DEBUGenvvar andprintf.