Creating a Compile and Build command
You can launch a compiler from Source Insight, using a custom command, and have the output captured and parsed for error messages. Then you can use Go To First Link and Go To Next Link to view each error in your source files.
To create a simple Compile command
To create a simple Compile command using the Microsoft ® C++ compiler:
1. Run the Custom Command command.
2. Type “Compile File” in the Name text box.
3. In the Run text box, type “cl %f”. This invokes the compiler on the current file. You could also invoke a “make” program or a batch file here instead. If you use a batch file, you must run the command processor first. For example, “cmd /c mybatch.bat”.
4. Turn on the Parse Source Links option. The default parse pattern is setup to parse the compiler error messages from the compiler output.
5. Turn on the Save Files First option so that your file is saved before running the compiler.
6. Click the Define button to save the new command. Alternatively, you can click the Menu or Keys buttons to define the new command and run the Menu Assignments or Keyboard Assignments commands, which will allow you to put the command on a menu or assign a key to it.
The Parse Source Links option causes Source Insight to search the compiler output and setup source links for each error message. In this case, the “link sources” are each error message in the compiler output file. The “link target” for each link is the file and line number given in each error message.
To Build a Project with Microsoft ® Developer Studio
1. Run the Custom Command command.
2. Select the Build Project command in the Command drop-down list. The Build Project custom command is predefined when you install Source Insight.
3. In the Run text box, type the following:
C:\MsDevPath\msdev project.dsp /make /rebuild
Where “MsDevPath” is the path to your msdev.exe program, and “project.dsp” is the name of the Developer Studio project.
This line invokes msdev.exe to rebuild the given project.
4. Turn on the Parse Source Links option. The default parse pattern is setup to parse the compiler error messages from the compiler output.
5. Turn on the Save Files First option so that your file is saved before building the project.
Viewing Compiler Errors
To view source lines with errors:
1. Run the Compile File custom command, which is defined as described above.
2. Assuming there are errors, when the compiler finishes the error messages will be in the “Compile File” window. Source Insight will automatically setup the source links and run the Go To First Link command. The first error message and the erroneous source line will be selected and made visible.
3. Run the Go To Next Link command. The next error message in the “Compile File” window is selected, and the target of that link is shown, as was the first error.
4. Continue to use the Go To Next Link command until all the links (error messages) have been visited. If there are no more links, then Source Insight beeps and the message, “No links.” will appear in the status bar.