February 20, 2019
Hot Topics:

Visual C++ 2005 IDE Enhancements, Part 6: Protect Against Buffer Overruns with the /GS Switch

  • July 8, 2005
  • By Nick Wienholt
  • Send Email »
  • More Articles »

In this final installment, I'll wrap up the coverage of what's new in the IDE with a look at Tracepoints, new project types, enhancements to the Server Explorer, and new functionality for creating C++ projects. Lastly, I'll provide answers to some of the questions that readers have posed as the series progressed.


Tracepoints are a new feature in Visual C++ 2005 that allows trace information to be generated when a certain line of code executes. Tracepoints operate much the same as a breakpoint, in that they are added to a particular statement, and "hit" when the statement is executed. In contrast to a breakpoint, that will halt execution when hit, a Tracepoint can generate a Trace statement, which will be visible in the Visual Studio output window, or the Tracepoint can run a Visual Studio macro.

The differences between breakpoints and Tracepoints are not distinct. A breakpoint can be configured to include tracing information or the execution of a macro, and a Tracepoint can be configured so that it does not output any debug information and does not run a macro, which in effect makes it a disabled breakpoint. If execution will not be halted at a particular statement, the normal red circle that appears in the left margin of the text editor will change to a diamond, as shown in Figure 1.

Figure 1: Visual Studio Tracepoint

It is worth pointing out that the Tracepoint in Figure 1 is on a native console application, and that configuring Tracepoints in managed and native code is identical. Figure 2 shows the configuration dialog box that is activated by the When Hit item of the Breakpoints Windows context menu. For the options selected in Figure 2, a trace statement is generated, a macro will print all open documents, and execution will be halted.

Figure 2: Tracepoint Configuration

The trace actions of a breakpoint or Tracepoint can also be examined by adding the When Hit column to the Breakpoints window, as shown in Figure 3.

Click here for a larger image.

Figure 3: Breakpoints Windows with When Hit actions displayed

New Project Types

Visual C++ 2005 offers out-of-the-box support for creating ATL, MFC, and Win32 Smart Device applications, so developers targeting Windows CE no longer have to contend with switching among multiple IDEs when going from the desktop and server world over to the embedded world. Visual Studio 2005 has a wealth of features that the VC++ 6 inspired Embedded Visual C++ lacked, and embedded developers should embrace the change.

For data-centric development, the new managed SQL Server project will be extremely useful. This project type makes it easy to create, deploy, and debug stored procedures written in C++/CLI. A stored procedure written in managed code is a public static method with the Microsoft::SqlServer::Server::SqlProcedure attribute applied. The method can return either void or an integer status code, and as with TSQL stored procedures, parameters are supported.

Assemblies containing a stored procedure need to be registered with the SQL Server 2005 server before they can be run; this can be accomplished by using the Deploy command from the Build menu. A managed code stored procedure uses ADO.NET syntax to manipulate data. The following bit of code simply deletes all the rows from a table. Note the absence of C#-style using statements or explicit clean-up of the connection and command objects that C++/CLI handles through deterministic cleanup.

void SQL::MyStoredProc()
   SqlConnection^ conn =
      gcnew SqlConnection("context connection=true");
   SqlCommand^ deleteCommand = gcnew SqlCommand
      ("delete from myTable", conn);

In addition to stored procedure templates, Visual C++ has trigger, aggregate function, user-defined type, and user-defined function templates available with SQL Server projects.

Page 1 of 2

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date