C/C++#
Getting Started#
Lattix can be used with C/C++ code compiled with your normal compiler and build system. The first step is to provide source, compile and link information to Lattix. There are three ways to do this:
Providing a build specification file (manually written or created with Lattix tool LXBuild)
Using the Project Configurer to specify files, directories and compiler options (not suitable for complex projects where there are many different compiler options)
The above pages will talk you through how to create your first Lattix project. Once you have completed those steps, continue reading about Lattix C/C++ details and capabilities below.
Additional Capabilities#
There are some useful scripts available that can be applied once a project has been created for additional visibility:
Combine Source and Header files: This script will go through your project and create a new subsystem for source and header files with the same name. This new subsystem is located in the same place where the subsystem for the source file is located. This capability is useful when you want to think of source files and header files as a single abstraction. For instance, you may have a source file called test.c and an associated header file called test.h. The script will group these files together into a single subsystem called test.
Generate Class View: This script will create a new project (using the LDI module) to create a pure class based view of the project. All atoms and dependencies which are not class based are eliminated. All you are left with are classes and dependencies. The directory structure is preserved allows you to extract that architecture from a pure object oriented perspective.
Improving Performance for Large Projects#
If you have performance problems with large C/C++ projects, you can adjust the options. See: Performance options for large projects
Atom and Dependency Kinds#
Atom Kinds#
The C/C++ module creates atoms of these kinds:
Header File
Source File
Macro
Enum
Class - class, struct, template or union
Field - data member of a class
Method - class function or method
Global Variable
Static Variable - variable scoped to a file
Global Function
Static Function - function scoped to a file
Template Class
Template Function
Dependency Kinds#
The C/C++ module creates these types of dependencies between atoms:
Override - a method overrides a method in a base class
Invoke - a method calls another
Inherit - a class has target class as a base class
Type Reference - general reference to a type
Macro - use of a macro
Address of Global - reference to the address of a global variable
Multiply Defined - symbol is multiply defined
Include - file include
Read Field - read access a data member of a class
Read Global - read access a global variable
Modify Field - modify a data member of a class
Modify Global - modify a global variable
Compiled With - Source files have a “Compiled With” dependency on the header files included in source’s compilation. Dependencies of this kind are only generated when the “Compute Visible Declaration Dependency Property” option is enabled. This dependency is filtered out by default.
C/C++ Reports#
There are a number of reports for the C/C++ Module. These reports include diagnostics (including errors) that were generated when the source code was compiled. It also includes a number of reports related to include file analysis. Please note that for some of these reports to work properly, the Compute Declaration Information property must be enabled at project creation. This property is needed because declarations are bypassed when dependencies are generated. As a result, the Externs report will generate an error if this property is not set. Furthermore, in the absence of this property, reports related to header files will not take declarations into account.
Diagnostics by File This report produces two sub-reports:
Files with Errors
Files with Warnings
Header Analysis This report produces 4 sub reports:
Headers not Included
Headers without dependencies
Headers included only for declarations
Headers included only to include other headers
Externs Analysis This report produces the following two sub reports:
Non-local Declarations in Source Files
Dependencies using non-local Declarations
Dependencies on Indirect Includes This report produces a 5 column report with the following fields: - Header File - Target/Provider atom in the header file (such as class, field, global data reference etc) - Source Location of the dependency in the source file for the target/provider atom - The type of dependency - The path(s) for the indirect dependency
Undefined Macros Produces a list of macros that weren’t defined and where those macros were referenced.
Missing Include Files Produces a list of include files that were missing, the name of the file that included them and a suggestion of the file that could be considered for inclusion (in case there was an error in the include path).
Cloned Files Lists files that are duplicates. Sometimes, files are copied by build systems. Occasionally, files are duplicated by developers. This report gives you a list of all the files which are identical.
Note
The Clang parser will be used to parse your code (http://clang.llvm.org/). Clang is part of the LLVM framework and is designed to support the C family of languages including C, C++ and Objective C. Clang is part of Apple’s development platform for iPhone, Macs and other devices. Clang has proven itself for its complete support for the C language family.