Introduction – Clang – Visual Studio

The Clang module can be used to analyze C/C++ code on Windows using Visual Studio solution and project files. Since the studio files contain the options to compile and link the executable, the Clang module can use that information to generate a build specification that can be used to analyze and extract dependencies (and create a dependency structure matrix).

Create your Project from Studio Files

Note that Lattix expects a Visual Studio environment when loading in the solution or project files. Therefore, you must have Visual Studio installed on the machine where Lattix is being run.

Here is a quick (7 minute) video on creating a C/C++ project in Lattix: Creating a C/C++ Project in Lattix Architect (8 min)

Clang Visual Studio Create Project Dialog

To create a new project from a Visual Studio solution or project files, here are the steps:

  1. Click on New Project on the home page to bring up the Create New Project dialog
  2. Select C/C++ (Clang) for Module Type
  3. Choose the option Visual Studio for Datasources
  4. Click on Add and specify the solution file or the project file(s), along with its Target
  5. Click on Create Project

Check for Errors

It is important after creating the project to check for errors that might have occurred as this could affect the results (dependencies shown). Check for errors by bringing up the Clang Reports using Reports->Clang Reports…->Diagnostics by File. Please pay particular attention to fatal errors, which are typically caused by missing include files. Most other errors will normally not have any significant effect on the analysis. Fix the errors and re-create (or update) the project.

  • Hint 1: To minimize the time, remember that you can test by compiling just a single source file that is giving you errors. The Options tab on the Create New Project dialog has an option called Include files matching these names. Simple enter the full path name of the file and then only that file will be compiled.
  • Hint 2: You can specify any additional include directories in the Options tab on the Create New Project dialog using the option Include Directories. You can also specify any additional compiler options using the option Compiler Options.
  • Hint 3: If any run across errors such as undefined types such as char16_t, char32_t, int16_t etc, these are C++11 standard types. You can enable the C++11 standard types by specifying the option -fms-compatibility-version=19 in Compiler Options. This is no longer needed in versions 10.1.2+, as this option is always enabled.
  • Hint 4: For Visual Studio 2010 based projects, if you run across errors such as fatal error: ‘SDKDDKVer.h’ file not found please add the include directory C:\Program Files(x86)\Microsoft SDKs\Windows\v7.0A\Include. The path may have to be adjusted based on your installation

Analyze your source code

You are now ready for further analysis using Lattix Architect. If you have not created a Dependency Structure Matrix view, you can create that now. Here are a couple of videos that can help:

Additional Resources

A well understood modular architecture may be the most effective technique for improving the quality and maintainability of complex code bases. At Lattix, we have helped some of the leading companies in the world improve the quality of their software and we can help you achieve the same results.

The Lattix Customer Portal contains additional whitepapers, customer case studies and articles. If you have questions on comments, you can contact us at support@lattix.com. To try Lattix on your code, email sales@lattix.com or call 978-664-5050