3 HEAD++ Global Initialization;;
5 Before anything from NoBug can be used, NoBug must be initialised. This
6 is archived by calling the `NOBUG_INIT()` macro before using any other of the
9 `NOBUG_INIT` can be called more than once, subsequent calls will be a no-op,
10 thus initialising in main and in libraries won't interfere with one another.
12 Care must be taken when one already using NoBug features from dynamic
13 initialized things in C++, one has to ensure that NoBug gets initialized first
14 possibly by pulling up a singleton at very first.
17 HEAD== Destroying NoBug;;
19 Since NoBug is intended to be available throughout its whole lifetime,
20 destroying it is not to be advised. Nevertheless, there is a destroy function
22 void nobug_destroy (void);
24 to shutdown NoBug, and this frees all resources associated with it.
25 This is mostly used in the NoBug testsuite itself to check for leaks,
26 and it might be useful for other programs which employ some kind of
30 HEAD== Init logging Flags;;
32 If you want to use environment variable controlled debuging, then you have to
33 initialize each defined flag with
35 NOBUG_INIT_FLAG(flagname)
39 NOBUG_INIT_FLAG_LIMIT(flagname, default)
41 or one of the C++ compatibility macros.
43 This is documented later in the xref:logconfig[logging configuration] chapter.
48 In Multithreaded programs you should assign an identifier to each
49 thread. A thread identifier is a string which will be automatically
50 appended with an underscore and an incrementing integer. It is is
51 created using the following:
53 NOBUG_THREAD_ID_SET(name)
55 For example, calling `NOBUG_THREAD_ID_SET("worker")` will result in a thread
56 identifier 'worker_1'.
58 If you don't set an identifier, then NoBug will automatically assign
59 one. This is further documented in the xref:multithreading[multi threading]
60 section of this manual.
63 PARA Initialization example; initexample; initialize NoBug, example
65 Thus the boilerplate code to pulling up NoBug in a multithreaded program looks
66 like (omit `NOBUG_THREAD_ID_SET()` in single threaded programs):
68 -------------------------------------------------------
70 NOBUG_DEFINE_FLAG(example);
77 NOBUG_THREAD_ID_SET("main");
78 NOBUG_INIT_FLAG(example);
82 -------------------------------------------------------