much the same as the static library method, except that:
* since the tracepoint provider is not part of the application
- anymore, `TRACEPOINT_DEFINE` _must_ be defined in one translation
- unit (C source file) of the _application_;
+ anymore, `TRACEPOINT_DEFINE` _must_ be defined, for each tracepoint
+ provider, in exactly one translation unit (C source file) of the
+ _application_;
* `TRACEPOINT_PROBE_DYNAMIC_LINKAGE` must be defined next to
`TRACEPOINT_DEFINE`.
+Regarding `TRACEPOINT_DEFINE` and `TRACEPOINT_PROBE_DYNAMIC_LINKAGE`,
+the recommended practice is to use a separate C source file in your
+application to define them, and then include the tracepoint provider
+header files afterwards, e.g.:
+
+~~~ c
+#define TRACEPOINT_DEFINE
+#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
+
+/* include the header files of one or more tracepoint providers below */
+#include "tp1.h"
+#include "tp2.h"
+#include "tp3.h"
+~~~
+
`TRACEPOINT_PROBE_DYNAMIC_LINKAGE` makes the macros included afterwards
(by including the tracepoint provider header, which itself includes
LTTng-UST headers) aware that the tracepoint provider is to be loaded
<pre class="term">
./app
</pre>
+
/* ... */
~~~
-Again, `TRACEPOINT_CREATE_PROBES` and `TRACEPOINT_DEFINE` must be
-defined in one, **and only one**, translation unit. Other C source
-files of the same application may include `tp.h` to use tracepoints
-with `tracepoint()`, but must not define
+Again, before including a given tracepoint provider header file,
+`TRACEPOINT_CREATE_PROBES` and `TRACEPOINT_DEFINE` must be defined in
+one, **and only one**, translation unit. Other C source files of the
+same application may include `tp.h` to use tracepoints with
+the `tracepoint()` macro, but must not define
`TRACEPOINT_CREATE_PROBES`/`TRACEPOINT_DEFINE` again.
This translation unit may be built as an object file by making sure to
`TRACEPOINT_DEFINE` must be defined by a translation unit of the
application. Since we're talking about static linking here, it could as
-well be defined in the file above, before `#include "tp.h"`. This is
-actually what [`lttng-gen-tp`](#doc-lttng-gen-tp) does.
+well be defined directly in the file above, before `#include "tp.h"`:
+
+~~~ c
+#define TRACEPOINT_CREATE_PROBES
+#define TRACEPOINT_DEFINE
+
+#include "tp.h"
+~~~
+
+This is actually what [`lttng-gen-tp`](#doc-lttng-gen-tp) does, and is
+the recommended practice.
Build the tracepoint provider:
}
~~~
-`TRACEPOINT_DEFINE` must be defined into exactly one translation unit (C
-source file) of the user application, before including the tracepoint provider
-header file. `TRACEPOINT_DEFINE` is discussed further in
+For each tracepoint provider, `TRACEPOINT_DEFINE` must be defined into
+exactly one translation unit (C source file) of the user application,
+before including the tracepoint provider header file. In other words,
+for a given tracepoint provider, you cannot define `TRACEPOINT_DEFINE`,
+and then include its header file in two separate C source files of
+the same application. `TRACEPOINT_DEFINE` is discussed further in
[Building/linking tracepoint providers and the user application](#doc-building-tracepoint-providers-and-user-application).
As another example, remember this definition we wrote in a previous
#define _TP_H
~~~
-Add this precompiler conditionals to ensure the tracepoint event generation
-can include this file more than once.
+Add these precompiler conditionals to ensure the tracepoint event
+generation can include this file more than once.
The `TRACEPOINT_EVENT()` macro is defined in a LTTng-UST header file which
must be included: