18.2 Versioning Options

By default, any D programs that you compile by using the dtrace -s command or that you specify by using the dtrace -P, -m, -f, -n, or -i command options, are bound to the most recent D programming interface version offered by the D compiler.

You can determine the current D programming interface version by using the -V option:

# dtrace -V
dtrace: Sun D 1.6.4
Note

Specifying the -Vv combination displays other version information, such as the version of the user-space binaries from the dtrace-utils package.

# dtrace -Vv
dtrace: Sun D 1.6.4
This is DTrace 1.0.4.
dtrace(1) version-control ID: 364a014be59b349d6222991d651d38422f170e7e
libdtrace version-control ID: 364a014be59b349d6222991d651d38422f170e7e

If you want to establish a binding to a specific version of the D programming interface, you can set the version option to an appropriate version string. Similar to other DTrace options that are described in Chapter 10, Options and Tunables, you can set the version option as follows:

# dtrace -x version=1.6 -n 'BEGIN{trace("hello");}'

Alternatively, you can use the #pragma D option syntax to set the option in your D program source file, for example:

#pragma D option version=1.6

BEGIN
{
  trace("hello");
}

If you use the #pragma D option syntax to request a version binding, you must place this directive at the top of your D program file, prior to any other declarations and probe clauses. If the version binding argument is not a valid version string or refers to a version that is not offered by the D compiler, an appropriate error message is produced and compilation fails. You can also use the version binding facility to cause the execution of a D script on an older version of DTrace to fail with an obvious error message.

Before compiling your program declarations and clauses, the D compiler loads the set of D types, functions, constants, and translators for the appropriate interface version into the compiler namespaces. Therefore, any version binding options that you specify simply control the set of identifiers, types, and translators that are visible to your program, in addition to the variables, types, and translators that your program defines. Version binding prevents the D compiler from loading newer interfaces that might define identifiers or translators that conflict with declarations in your program source code and would therefore cause a compilation error. See Section 2.8.1, “Identifier Names and Keywords” for tips on selecting identifier names that are unlikely to conflict with interfaces offered by future versions of DTrace.