-
Notifications
You must be signed in to change notification settings - Fork 0
debug.h ~ debug ~ init
Baptistou edited this page Feb 10, 2020
·
5 revisions
std::ios& init(std::ios &ios) noexcept;
Initializes iostream properties to their default value.
debug::init
also permits to set debug flag according to the macro DEBUG
which can be defined before include or as compiler command line argument -DDEBUG=value
. If no value is set, the macro DEBUG
expands to value 1
.
The following properties are initialized :
Name | Value |
---|---|
debug::flag | if macro DEBUG is defined then debug::level<DEBUG> else debug::off
|
ios.clear | std::goodbit |
ios.exceptions | disabled like debug::noexcept_on_fail
|
ios.fill | whitespace character ' '
|
ios.flags | std::dec | std::skipws |
ios.precision | 6 |
-
ios
--> reference to an iostream object.
Returns a reference to ios
passed in argument.
Never throws exception.
If a program starts as below :
#include <iostream>
#include <JLC/debug.h>
int main(){
std::cout << debug::init;
std::cin >> debug::init;
}
Then we can control our debug flag through compiler command line arguments :
//diagnostics and debug flag disabled
g++ -c test.cpp
//diagnostics and debug flag enabled
clang++ -c test.cpp -DDEBUG
//diagnostics enabled and debug flag disabled
g++ -c test.cpp -DDEBUG=0
//diagnostics enabled and debug flag set to level3
clang++ -c test.cpp -DDEBUG=3