Skip to content

How do I run PC-lint from inside Microsoft Visual Studio?

    
/*
The entire contents of this entry constitute a configuration file
with options to use the correct output format for Visual Studio
integration. This file can be saved and used where "env-vc10.lnt"
is mentioned.

This entry describes adding a menu option to run PC-lint Plus.
You must generate a compiler and project configuration separately.
See section 2.3 of the PDF reference manual.

If you are using Microsoft Visual Studio and you wish to invoke PC-lint from that environment then add one or more commands to the Tools menu as follows. Simple Check ------------ For example, to add a simple facility to lint the current file you may do the following: 1. From the Tools Menu choose "External Tools ..." 2. Click the "Add" button. 3. You will now be able to enter the fields of this Tool. Modify them so that they approximate the following: Title: PC-lint (Simple Check) Command: c:\lint\lint-nt.exe Arguments: -i"c:\lint" std.lnt env-vc10.lnt "$(ItemFileName)$(ItemExt)" Initial Directory: $(ItemDir) X_Use Output Window __Prompt for arguments __Close on exit Please note that you will have to change the "Command:" path if the PC-lint Installation Directory is anything other than c:\lint and you will have to change the "Arguments:" line if the Configuration Directory is anything other than c:\lint 4. Select OK to return to the main environment. This will result in the Tools menu containing the additional item "PC-lint (Simple Check)". Checking 'X' on 'Use Output Window' is important because in this way you can advance from error to error using the F8 key (Shift F8 to reverse). Strings of the form $(...) are called macros and can be typed in directly as shown or can be selected from a menu by clicking a right arrow in the dialog box. $(ItemFileName) refers to the file name of the currently edited file without its path and without its extension. $(ItemExt) is its extension. $(ItemDir) represents the file's directory. You will probably want to advance your new tool upward into the initial position of all tools while you are testing and modifying the command. You can do this by using the "Move Up" button that appears on the External Tools dialog. The benefits of using "Initial Directory" are that file-names in lint error messages will not be so long, and, also, this directory can contain a std.lnt that overrides the global std.lnt in the Configuration Directory. This Simple Check is fine to check stand-alone modules but to check projects or to unit check modules that are in projects we need to go a bit further ... Suppressing Messages ----------- -------- Suppressing messages is normally done by adding message suppression options to a file. For example, -e550 will suppress message 550. There are numerous other options to suppress messages. As the documentation indicates, the file c:\lint\options.lnt (where c:\lint\ is the Configuration Directory) is the presumed container of your overall suppression policy. (Note: options.lnt is referenced by std.lnt). Add a message suppression here and you will affect all linting employing that configuration. To suppress messages for a particular project (or for all projects within a given project directory) you may do the following: Create a file std.lnt that is contained in the project directory. Make it refer back to the std.lnt in the Configuration Directory. Then add additional message suppression options or indeed any options you want. For example it might contain: c:\lint\std.lnt // reference to original std.lnt -e550 // project-specific option In this way suppression is limited to a particular project. Tool Bar -------- You also have the option of creating a PC-lint toolbar within your Visual C++ IDE. First, create one or more tools as described above. You will need to know the number(s) of the tool(s) you want to place on the tool bar. This can only be done by the painful and laborious task of counting. Using the list provided by "Tools"/"External Tools", jot down the numbers (starting with 1 at the top) of all the tools to be added to the tool bar. We recommend placing all the PC-lint tools on a single tool bar. Then select Customize from the Tools menu. Select the Toolbars tab and click the New... button. Give the Toolbar a name (E.g., PC-lint) in the dialog box provided and click "OK". Confirm that the new toolbar is now floating on the desktop and that a check has been placed in the check box next to the new toolbar name. Then click on the Commands tab and select the "Toolbar:" radio button. Open the drop down list and select "PC-Lint" from the choices. Click the "Add Command..." button to reveal the "Add Command" window. In the "Categories:" box scroll down to and select the "Tools" item. In the "Commands:" box scroll down to and select the appropriate "External Command" numbered item that corresponds to the desired PC-Lint command, then click the OK button to add the selected item to the PC-Lint toolbar. Repeat the "Add Command..." process for each desired PC-Lint command the you wish to place on the PC-Lint toolbar. If you want to add a button image to the toolbar, you can choose one via the Modify Selection button. Click Close and you now have your own PC-lint for C/C++ button. (Note: If you change the location of the PC-lint menu item on the Tools menu, you will change the subscript and you will need to change the button(s) on the toolbar.) */ -"format=%(%F(%l):%) error %n: (%t -- %m)" // Messages will contain // file information (%F), the line number (%l), the // message number (%n), message type (%t) and message text (%m). -hF2 // Make sure we ALWAYS provide file information ('F') and use 2 // lines (one for the source line in error and one for the // message). -width(0) // don't break messages at any particular width -t4 // Presume that tabs are every 4 stops +e900 // issue a message at termination.

Feedback and Knowledge Base