Trond Norbye
2006-Aug-14 07:00 UTC
[dtrace-discuss] Why does dtrace -h remove const qualifier?
If I have the following definition: provider foo { probe bar(const char*); }; and creates the headerfile (snv 43) with dtrace -h I get: extern void __dtrace_foo___bar(char *); This is a "problem" for me (ok, I could add an explicit cast each time I fire the probe, or edit the generated headerfile by hand...), since it generates compilation errors when I call the probe in a C++ context: "a.cc", line 6: Error: Formal argument 1 of type char* in call to __dtrace_foo___bar(char*) is being passed const char*. So, is this a bug in dtrace or is there a valid reason for removing the constness in the function prototype... Trond This message posted from opensolaris.org
Adam Leventhal
2006-Aug-15 21:34 UTC
[dtrace-discuss] Why does dtrace -h remove const qualifier?
Hey Trond, This is a bug in libdtrace. The problem is that the DTrace compiler drops const declarations. The two solutions we''ve thought of for this problem are to enhance the compiler (a bunch of work) or make the prototypes in the generated header files _all_ be const (simpler, but not as simple as it had originally seemed). Go ahead and file the bug in library/libdtrace and I''ll add some notes to the bug report. I''ve been meaning to put together a page of ways people from the community could improve DTrace -- this bug would be on that list. Adam On Mon, Aug 14, 2006 at 12:00:35AM -0700, Trond Norbye wrote:> If I have the following definition: > provider foo { > probe bar(const char*); > }; > > and creates the headerfile (snv 43) with dtrace -h I get: > extern void __dtrace_foo___bar(char *); > > This is a "problem" for me (ok, I could add an explicit cast each time I fire the probe, or edit the generated headerfile by hand...), since it generates compilation errors when I call the probe in a C++ context: > "a.cc", line 6: Error: Formal argument 1 of type char* in call to __dtrace_foo___bar(char*) is being passed const char*. > > So, is this a bug in dtrace or is there a valid reason for removing the constness in the function prototype... > > Trond > > > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Adam Leventhal, Solaris Kernel Development http://blogs.sun.com/ahl