3.4 Options
Table
2 summarizes the platform-independent options supported by
ac++. Platform specific options will be explained in section
4. All options can either be passed as command line arguments or by the configuration file, which is referenced by the environment variable PUMA_CONFIG (see section
2). ’–’ in any of the columns WPT or STU means that this option has no meaning in the corresponding translation mode.
The upper part of the table lists ac++-specific options, while the options in the lower part are widely-known from other compilers like g++.
Option |
WPT |
STU |
|
-p|--path <arg> |
X |
X |
Defines a project directory
|
-e|--extension <arg> |
X |
– |
Filename extension of translation units
|
-v|--verbose <arg> |
X |
X |
|
-c|--compile <arg> |
– |
X |
|
-o|--output <arg> |
– |
X |
|
-g|--generate |
– |
X |
|
-i|--include_files |
– |
X |
Generate manipulated header files
|
-a|--aspect_header <arg> |
X |
X |
Name of aspect header file or 0
|
-r|--repository <arg> |
X |
X |
Name of the project repository
|
-x|--expr <arg> |
– |
– |
Match a pointcut expression (arg) agaist the project repository
|
--config <arg> |
X |
X |
Parser configuration file
|
-k|--keywords |
X |
X |
Allow AspectC++ keywords in normal project files
|
--introduction_depth <arg> |
X |
X |
Set the maximum depth for nested introductions
|
--no_line |
X |
X |
Disable generation of #line directives
|
--gen_size_type <arg> |
X |
X |
use a specific string as size_t
|
--warn... |
X |
X |
enable a weaver warning that is suppressed by default
|
--no_warn... |
X |
X |
suppress a specific weaver warning
|
--problem... |
X |
X |
enable back-end compiler problem workaround (see 4.2)
|
--no_problem... |
X |
X |
disable back-end compiler problem workaround
|
--builtin_operators |
X |
X |
Support advice on built-in operator calls
|
--data_joinpoints |
X |
X |
Support data-based join points, e.g. get(), set(), ...
|
--attributes |
X |
X |
Support C++11-attribute-based join points
|
--no_attributes |
X |
X |
Disable support user-defined attributes
|
-I <arg> |
X |
X |
|
-D <name>[=<value>] |
X |
X |
|
-U <name> |
X |
X |
|
--include <arg> |
X |
X |
|
Table 2: ac++ Compiler Option Summary
3.4.1 -p|--path <arg>
This option defines the name of a project directory tree <arg>. The option can be used more than once if several directories belong to the project. At least one -p options is always needed when ac++ has to transform code, even in STU mode.
3.4.2 -d|--dest <arg>
With -d a target directory for saving is selected. It corresponds to the last -p option. For example, if two directories belong to a project they would be described in STU mode with
and in WPT with two source/target pairs:
-p source1 -d target1 -p source2 -d target2
In STU mode
-d makes only sense in combination with
-i to generate header files for a library (see
3.4.7).
3.4.3 -e|--extension <arg>
In WPT mode ac++ searches in all project directories for translation units to transform. Translation units are identified by their filename extension. The default is “cc”, which means that all files ending with “.cc” are handled. By using the option -e cpp or -e cxx you can select other frequently used filename extensions. The option can be used more than once, but only the last one is effective.
In WPT mode ac++ generates a file called ac_gen.<extension>. This extension is also taken from the -e option, if one is provided.
3.4.4 -v|--verbose [<arg>]
The compiler can print message on the standard output device, which describe what it is currently doing. These message can be printed with different levels of details. You can select this level with the parameter <arg>. The range is from 0, which means no output, to 9, which means all details. The option -v0 is the same as having no -v option at all. -v without <arg> is the same as -v3.
The -v option can be used more than once but only the last one is effective.
3.4.5 -c|--compile <arg>
The -c option is used to select an input file for ac++ in the STU mode. Using it more than once is possible, but only one is effective. There are no restrictions on the filename extension. ac++ expects that the file contains AspectC++ source code.
3.4.6 -o|--output <arg>
With the -o option one can select the name of the output file, i.e. the name of the target of the code transformation, in STU mode. If this option is not used, the default output filename is ac.out. Note that the output filename is not derived from the input file name as it is done by other compilers.
3.4.7 -i|--include_files
The
-i option has to be used if the source code of the project should be compiled into a library and
ac++ should run in STU mode (see
3.2). When a translation unit is transformed by using
-c and
-o in STU mode no manipulated header files are generated. All include files are expanded within the generated source code. This is fully sufficient if the translation units will then be compiled and linked directly. However, if a library should be provided the client needs a library file (an archive)
and manipulated header files. These can be generated with
-i. The generation results in a directory tree with the same structure as the input directory tree specified by
-p exhibits. Use the
-d option to select the target directory name(s).
Note that at the moment only and all files with the extension .h are considered to be include files. This is rather inflexible and will be improved in future releases.
3.4.8 -a|--aspect_header <arg>
By default
ac++ searches all files with the filename extension
.ah in the project directory tree(s) and allows all aspects defined in these files to affect the current translation unit. If you are looking for a simple mechanism to deactivate aspects at compile-time, or if
.ah does not conform to your local conventions, or if not all aspects should affect all translation units (be careful! See
5.1), the
-a option might help.
The option may be used more than once and each of them selects one aspect header that has to be considered for the current translation unit in STU mode or all translation units in WPT mode. If no aspect header should be considered use -a0.
3.4.9 -r|--repository <arg>
The “project repository” is an XML-based description of global information about an AspectC++ development project that is compiled with ac++. It fulfills two purposes:
- It is a vehicle to transport information from one compiler run to another
- It might be used by integrated development environments to visualize the join points where aspects affect the component code.
The -r option is used to define the name of the project repository file. However, this is an experimental feature. The file format might be subject to future changes. The uniqueness of join point IDs is only guaranteed if the project is compiled with a project repository. If a file with the given name does not exist, ac++ will create a new repository file. If the file exists, but is empty or does not contain valid data, ac++ terminates with an error message. A warning messages will be printed if the version of the weaver, which created the project repository, differs from the current ac++ version.
3.4.10 -x|--expr <arg>
This option is used to match a pointcut expression, given as argument <arg>, against a project repository file. The project repository filename has to be provided with the -r option. For example the following command prints all nested class known in the “PragmaOnceObserver” test program in the AspectC++ development tree.
prompt> ac++ -x ’"%::%"’ -r PragmaOnceObserver/repo.acp
ObserverPattern.ah:12: Class "ObserverPattern::Subject"
ObserverPattern.ah:13: Class "ObserverPattern::Observer"
This example illustrates the mechanism with a more complicated pointcut expression:
prompt> ac++ -x ’call("%") && within("% main()")’ -r ...
main.cc:29: Call "void ObserverPattern::addObserver( ...
main.cc:32: Call "void ObserverPattern::addObserver( ...
main.cc:34: Call "void ClockTimer::Tick()"
main.cc:37: Call "void ClockTimer::Tick()"
Note that pointcut expression contain quotes (“). Make sure that quotes are not removed by the command shell. On Linux systems it is a convenient solution to enclose the pointcut expression in single quotes, e.g. ’”%”’.
3.4.11 --config <arg>
Besides setting the environment variable PUMA_CONFIG this options can be used to set the path to the parser configuration file.
3.4.12 -k|--keywords
By default the AspectC++ keywords aspect, pointcut, advice, slice and attribute are only treated as keywords in aspect header files. If they are used in normal project files, ac++ interprets them as normal identifiers. By this design decision aspects can be woven into legacy code even if the code uses the AspectC++ keywords as normal identifiers.
If the AspectC++ keywords should be interpreted as keywords in normal project files as well, the command line option -k or --keywords has to be used.
In files that do not belong to the project, e.g. standard library header files, the AspectC++ keywords are always regarded as normal identifiers, even if -k or --keywords is used.
If any of the AspectC++ keywords is generated by a macro, the classification as keyword or identifier is based on the file in which the macro expansion takes place. It does not depend on the location of the macro definition.
3.4.13 --introduction_depth <arg>
AspectC++ introductions may affect introduced code. This is called a “nested introduction”. In order to avoid problems with infinitely nested introductions, ac++ checks the “depth” of a nested introduction and does not allow a depth that exceeds the given maximum <arg>. The default value for <arg> is 10.
3.4.14 --no_line
When ac++ manipulates files, e.g. by inserting generated code, it also inserts #line directives. Inserting these directives can be disabled with the --no_line option. Normally, #line directives are only generated by C preprocessors. The directives are important for back-end compiler error messages and source code debuggers. Without the #line generation these numbers correspond to the lines in the generated code, while they correspond to the source code written by the programmer otherwise.
3.4.15 --gen_size_type <arg>
ac++ generates a new operator, which has size_t in its argument type list. As the generated code shall not include the respective header file (to avoid portability problems), the weaver normally generates the name of the right type. However, in case of cross-compilation the type on the target platform might differ. Then it is possible to provide a string with this option, which is directly used in the constructor’s argument list.
3.4.16 --problem...
An option like this is used to enable a back-end compiler-specific code generation workaround. This is sometimes needed, because the C++ compilers differ in their degree of standard conformance. For details about the workarounds needed for each back-end refer to section
4.2.
3.4.17 --no_problem...
This option can be used to disable a back-end compiler-specific code generation workaround which is enabled by default.
3.4.18 --warn_...
With this option the weaver is instructed to print specific warnings that are otherwise suppressed. Table
3 lists the names of warnings currently supported by the weaver.
3.4.19 --no_warn_...
The warnings listed in table
3 can be suppressed with
--no_warn_<
Name>.
Warning Name |
Condition |
deprecated |
a deprecated syntax is being used |
macro |
macro-generated code would have to be transformed |
3.4.20 --builtin_operators
This option is needed if you want to use the pointcut function builtin(). For more information on this feature consult the language reference manual.
3.4.21 --data_joinpoints
This option is needed if you want to use the pointcut functions get(), set(), and ref(). For more information on this feature consult the language reference manual.
3.4.22 --attributes/--no_attributes
This option is needed if you want to use attributes in C++11-Style (e.g. [[noreturn]]). It is enabled by default and can be disabled with --no_attributes. For more information on this feature consult the language reference.
3.4.23 -I <arg>
The option -I adds the directory <arg> to the list of directories to be searched for header files. It can be used more than once. The compiler ac++ needs to know all directories, where header files for the current translation unit might be located.
In case of system headers there are often a lot of these directories. To make the setup of ac++ more convenient we provide the ag++ --gen_config command. The command calls the g++ compiler to get all these paths. Users of non-supported back-end compilers have to find out this list on their own.
3.4.24 -D <name>[=<value>]
With -D a preprocessor macro <name> will be defined. Without the optional value assignment the macro will get the value 1. The option can be used more than once.
In most cases your source code expects some standard macros to be defined like win32, linux, or i386. And even if your code doesn’t use them directly, they are often required to be set correctly by system header files. Thus, for the ac++ parser a correct set of these macros has to be defined. For g++ users we provide a command called ag++ that calls the compiler to get the list of these macros. Users of non-supported back-end compilers have to find out this list on their own.
3.4.25 -U <name>
This option can be used to undefine a previously defined macro.
3.4.26 -include <arg>
The
-include option can be used to include a file
<arg> into the compiled translation unit(s) even though there is no explicit
#include directive given in the source code. If multiple
-include options are given on the command line, the files are included in the same order (from left to right). If you use the option in STU mode make sure that the back-end compiler is not forced to include the same files again (read details in
5.1.2).