.. _C/C++ support:

C/C++ support
=============



C and C++ support is provided on top of the C Development Tooling Eclipse (CDT) plugin. DVT provides the following features on top of CDT:

-  Out of the box C/C++ project configuration by reusing :ref:`Build Configurations`
-  C/C++ project creation through the DVT :ref:`Command Line Interface`
-  :ref:`DVT Auto-Linked` C/C++ source files and headers located outside the project
-  SystemVerilog DPI :ref:`Hyperlinks`
-  C and C++ types in the DVT :ref:`Types View`
-  C and C++ compiled files in the DVT :ref:`Compile Order View`
-  C and C++ preprocessing symbols in the DVT |macros-view-ref|
-  Built-in :ref:`Content Filters` for common libraries (C/C++ system headers, SystemC, PSS C)

**Installation**

The CDT plugin is already bundled in DVT KIT distributions, and has to be enabled using the :ref:`dvt_kit_installer.sh` script:
 
 dvt_kit_installer.sh install CDT

This command installs the CDT plugin and the DVT CDT Integration plugin as well.

**Project Natures**

Right click on a project and choose **Change DVT Nature**:

.. figure:: ../../images/common/change_DVT_nature.png



-  The **C/C++ Language** nature enables basic CDT integration features: project configuration and SystemVerilog DPI cross-linking when the **SystemVerilog** nature is also enabled
-  The **C/C++ Language Extended** nature enables advanced features like C/C++ content shown in the DVT views

**Project Build**

For a DVT project with any C/C++ Language nature, the build process includes a scan for C/C++ files and CDT re-indexing.

.. note:: 

  By default the CDT Codan, the code analysis engine which performns semantic checks in C and C++ code, is not active.
  
  Using the **+dvt_run_codan+FULL+INCR** directive you can specify when CDT Codan analysis should be performed: FULL - at full build, INCR - at incremental build (for example when saving a file).

During full build, DVT collects the following C/C++ specific directives from your build configuration file and uses them to configure CDT and to scan for all included C/C++ files:

-  -I
-  -D
-  -L
-  -l
-  -imacros
-  -include

The **gcc** args mentioned above are also collected from the strings passed to the following build configuration directives:

-  -CFLAGS
-  -ccflags
-  -ccargs


The C/C++ sources located outside the project directory are automatically linked inside the project under the DVT Auto-Linked folder.

The C/C++ sources located inside the project but not included by the C/C++ top files specified in the build configuration are automatically excluded from the CDT build.

The following DVT specific build configuration directives are available:

.. list-table::
   :header-rows: 1
   :widths: auto

   * - Directive
     - Description
   * - +dvt_gcc+</path/to/gcc_executable>
     - Specify location of GCC executable (used when scanning for included C/C++ files and injected in the CDT project configuration).
   * - +dvt_gcc_args+"args string"
     - Specify extra arguments for the GCC executable (used when scanning for included C/C++ files and injected in the CDT project configuration).
   * - +dvt_gcc_timeout+<timeout>
     - Timeout in seconds when running GCC. Set 0 to disable timeout. Default: 40 seconds.




