|
|||
2. Types, Operators, and Expressions 8. Type and Constant Definitions 34. Statically Defined Tracing for User Applications |
Versioning OptionsBy default, any D programs you compile using dtrace -s or specify using the dtrace -P, -m, -f, -n, or -i command-line 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 using the dtrace -V option: $ dtrace -V dtrace: Sun D 1.0 $ If you wish 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 (see Chapter 16, Options and Tunables), you can set the version option either on the command-line using dtrace -x: # dtrace -x version=1.0 -n 'BEGIN{trace("hello");}' or you can use the #pragma D option syntax to set the option in your D program source file: #pragma D option version=1.0 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 not offered by the D compiler, an appropriate error message will be produced and compilation will fail. You can therefore also use the version binding facility to cause execution of a D script on an older version of DTrace to fail with an obvious error message. Prior to 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 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 may define identifiers or translators that conflict with declarations in your program source code and would therefore cause a compilation error. See Identifier Names and Keywords for tips on how to pick identifier names that are unlikely to conflict with interfaces offered by future versions of DTrace. |
||
|