Project

General

Profile

Actions

Feature #338

closed

Trace probe can not be compiled with g++

Added by Ansgar Radermacher about 12 years ago. Updated over 11 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
09/17/2012
Due date:
% Done:

100%

Estimated time:

Description

I'd like to use LTTng in the context of C++ projects. The trace probe itself is always a "C" file, in the examples called tp.c.

If I use a C++ file instead, e.g. by renaming the tp.c to tp.cpp, the compilation fails, since the two enumerations alloc and sync are defined within the scope of the lttng_ust_lib_ring_buffer_config structure and thus their literals are not found (there are additional problems, if I try to define these two enumerations on top level).

Using a C file instead of a C++ is sometimes a bit problematic. In my case, I am integrating LTTng into the Papyrus code generation and I do not like mixing the C and C++ code generation (although possible).


Files

Actions #1

Updated by Zifei Tong over 11 years ago

I did some research on this today, and finally made g++ compile 'hello.cxx' example.

The main problem is designated initializer. G++ do support designated initializer, however only 'trivial designated initializers' are supported, otherwise it will complain: 'sorry, unimplemented: non-trivial designated initializers not supported'.

After some trial-and-error, it seems that 'trivial designated initializers' means no out-of-order initialization and no missing initialization (except the fields on the tail of a struct).
And nested initialization should be done in the form {.foo = {.bar = 1}} instead of {.foo.bar = 1}.

So I reordered some initializers, add some fields, and change nested initializations in the above odd form to make g++ happy.

Actions #2

Updated by Zifei Tong over 11 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF