Skip to content

Commit f2bcd6d

Browse files
authored
Merge pull request #1382 from msebolt/walkthrough-review-pr4
walkthrough review pr4
2 parents e20e109 + 1f0f58f commit f2bcd6d

3 files changed

+65
-39
lines changed

docs/windows/walkthrough-creating-a-standard-cpp-program-cpp.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Walkthrough: Creating a Standard C++ Program (C++) | Microsoft Docs"
33
ms.custom: "get-started-article"
4-
ms.date: "11/04/2016"
4+
ms.date: "09/18/2018"
55
ms.technology: ["cpp-windows"]
66
ms.topic: "conceptual"
77
f1_keywords: ["vcfirstapp", "vccreatefirst"]
@@ -31,41 +31,48 @@ To complete this walkthrough, you must understand the fundamentals of the C++ la
3131

3232
1. Create a project by pointing to **New** on the **File** menu, and then clicking **Project**.
3333

34-
2. In the **Visual C++** project types pane, click **Windows Desktop**, and then click **Windows Console Application**.
34+
1. In the **Visual C++** project types pane, click **Windows Desktop**, and then click **Windows Console Application**.
3535

36-
3. Type a name for the project.
36+
> [!NOTE]
37+
> For versions of Visual Studio older than 2017, in the **New Project** dialog box, expand **Installed** > **Templates** > **Visual C++**, and then select **Win32**. In the center pane, select **Win32 Console Application**.
38+
39+
Type a name for the project.
3740

3841
By default, the solution that contains the project has the same name as the project, but you can type a different name. You can also type a different location for the project.
3942

4043
Click **OK** to create the project.
4144

42-
4. If **Solution Explorer** is not displayed, on the **View** menu, click **Solution Explorer**.
45+
> [!NOTE]
46+
> For versions of Visual Studio older than 2017, complete the **Win32 Application Wizard**. Click **Next**, then make sure **Console Application** is selected and uncheck the **Precompiled Headers** box. Click **Finish**.
47+
48+
1. If **Solution Explorer** is not displayed, on the **View** menu, click **Solution Explorer**.
4349

44-
5. Add a new source file to the project, as follows.
50+
1. Add a new source file to the project, as follows.
4551

4652
1. In **Solution Explorer**, right-click the **Source Files** folder, point to **Add**, and then click **New Item**.
4753

48-
2. In the **Code** node, click **C++ File (.cpp)**, type a name for the file, and then click **Add**.
54+
1. In the **Code** node, click **C++ File (.cpp)**, type a name for the file, and then click **Add**.
4955

5056
The .cpp file appears in the **Source Files** folder in **Solution Explorer**, and the file is opened in the Visual Studio editor.
5157

52-
6. In the file in the editor, type a valid C++ program that uses the C++ Standard Library, or copy one of the sample programs and paste it in the file.
58+
1. In the file in the editor, type a valid C++ program that uses the C++ Standard Library, or copy one of the sample programs and paste it in the file.
5359

54-
7. Save the file.
60+
1. Save the file.
5561

56-
8. On the **Build** menu, click **Build Solution**.
62+
1. On the **Build** menu, click **Build Solution**.
5763

5864
The **Output** window displays information about the compilation progress, for example, the location of the build log and a message that indicates the build status.
5965

60-
9. On the **Debug** menu, click **Start without Debugging**.
66+
1. On the **Debug** menu, click **Start without Debugging**.
6167

6268
If you used the sample program, a command window is displayed and shows whether certain integers are found in the set.
6369

6470
## Next Steps
6571

66-
**Previous:** [Console Applications in Visual C++](../windows/console-applications-in-visual-cpp.md). **Next:**[Walkthrough: Compiling a Native C++ Program on the Command Line](../build/walkthrough-compiling-a-native-cpp-program-on-the-command-line.md).
72+
**Previous:** [Console Applications in Visual C++](../windows/console-applications-in-visual-cpp.md)<br/>
73+
**Next:** [Walkthrough: Compiling a Native C++ Program on the Command Line](../build/walkthrough-compiling-a-native-cpp-program-on-the-command-line.md)<br/>
6774

6875
## See Also
6976

7077
[C++ Language Reference](../cpp/cpp-language-reference.md)<br/>
71-
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)
78+
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)<br/>

docs/windows/walkthrough-creating-and-using-a-static-library-cpp.md

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Walkthrough: Creating and Using a Static Library (C++) | Microsoft Docs"
33
ms.custom: "get-started-article"
4-
ms.date: "07/12/2018"
4+
ms.date: "09/18/2018"
55
ms.technology: ["cpp-windows"]
66
ms.topic: "conceptual"
77
dev_langs: ["C++"]
@@ -37,35 +37,44 @@ An understanding of the fundamentals of the C++ language.
3737

3838
1. On the menu bar, choose **File** > **New** > **Project**.
3939

40-
2. In the left pane of the **New Project** dialog box, expand **Installed, Visual C++**, and then select **Windows Desktop**.
40+
1. In the left pane of the **New Project** dialog box, expand **Installed** > **Visual C++**, and then select **Windows Desktop**. In the center pane, select **Windows Desktop Wizard**.
4141

42-
3. In the center pane, select **Windows Desktop Wizard**.
42+
> [!NOTE]
43+
> For versions of Visual Studio older than 2017, in the **New Project** dialog box, expand **Installed** > **Templates** > **Visual C++**, and then select **Win32**. In the center pane, select **Win32 Console Application**.
44+
45+
1. Specify a name for the project—for example, *MathFuncsLib*—in the **Name** box. Specify a name for the solution—for example, *StaticLibrary*—in the **Solution Name** box. Choose the **OK** button.
46+
47+
- For Visual Studio 2017,
4348

44-
4. Specify a name for the project—for example, *MathFuncsLib*—in the **Name** box. Specify a name for the solution—for example, *StaticLibrary*—in the **Solution Name** box. Choose the **OK** button.
49+
1. Under **Application type**, select **Static Library (.lib)**.
4550

46-
5. Under **Application type**, select Static Library (.lib).
51+
1. Under **Additioal Options**, un-check the **Precompiled header** check box.
4752

48-
6. Under **Additional Options**, un-check the **Precompiled header** check box.
53+
1. Choose **OK** to create the project.
4954

50-
7. Choose **OK** to create the project.
55+
- For versions of Visual Studio older than 2017,
56+
57+
1. Click **Next**.
58+
59+
1. Under **Application type**, select **Static library**. Then uncheck the **Precompiled header** box and choose **Finish**.
5160

5261
## <a name="AddClassToLib"></a> Adding a class to the static library
5362

5463
### To add a class to the static library
5564

56-
1. To create a header file for a new class, open the shortcut menu for the **MathFuncsLib** project in **Solution Explorer**, and then choose **Add**, **New Item**. In the **Add New Item** dialog box, in the left pane, under **Visual C++**, select **Code**. In the center pane, select **Header File (.h)**. Specify a name for the header file—for example, *MathFuncsLib.h*—and then choose the **Add** button. A blank header file is displayed.
65+
1. To create a header file for a new class, open the shortcut menu for the **MathFuncsLib** project in **Solution Explorer**, and then choose **Add** > **New Item**. In the **Add New Item** dialog box, in the left pane, under **Visual C++**, select **Code**. In the center pane, select **Header File (.h)**. Specify a name for the header file—for example, *MathFuncsLib.h*—and then choose the **Add** button. A blank header file is displayed.
5766

58-
2. Add a class named `MyMathFuncs` to do common mathematical operations such as addition, subtraction, multiplication, and division. The code should resemble this:
67+
1. Add a class named `MyMathFuncs` to do common mathematical operations such as addition, subtraction, multiplication, and division. The code should resemble this:
5968

6069
[!code-cpp[NVC_Walkthrough_Create_Static_Lib#100](../windows/codesnippet/CPP/walkthrough-creating-and-using-a-static-library-cpp_1.h)]
6170

62-
3. To create a source file for the new class, open the shortcut menu for the **MathFuncsLib** project in **Solution Explorer**, and then choose **Add**, **New Item**. In the **Add New Item** dialog box, in the left pane, under **Visual C++**, select **Code**. In the center pane, select **C++ File (.cpp)**. Specify a name for the source file—for example, *MathFuncsLib.cpp*—and then choose the **Add** button. A blank source file is displayed.
71+
1. To create a source file for the new class, open the shortcut menu for the **MathFuncsLib** project in **Solution Explorer**, and then choose **Add** > **New Item**. In the **Add New Item** dialog box, in the left pane, under **Visual C++**, select **Code**. In the center pane, select **C++ File (.cpp)**. Specify a name for the source file—for example, *MathFuncsLib.cpp*—and then choose the **Add** button. A blank source file is displayed.
6372

64-
4. Use this source file to implement the functionality for **MyMathFuncs**. The code should resemble this:
73+
1. Use this source file to implement the functionality for **MyMathFuncs**. The code should resemble this:
6574

6675
[!code-cpp[NVC_Walkthrough_Create_Static_Lib#110](../windows/codesnippet/CPP/walkthrough-creating-and-using-a-static-library-cpp_2.cpp)]
6776

68-
5. Compile the static library by selecting **Build** > **Build Solution** on the menu bar. This creates a static library that can be used by other programs.
77+
1. Compile the static library by selecting **Build** > **Build Solution** on the menu bar. This creates a static library that can be used by other programs.
6978

7079
> [!NOTE]
7180
> When you build on the Visual Studio command line, you must build the program in two steps. First, run `cl /c /EHsc MathFuncsLib.cpp` to compile the code and create an object file that's named `MathFuncsLib.obj`. (The `cl` command invokes the compiler, Cl.exe, and the `/c` option specifies compile without linking. For more information, see [/c (Compile Without Linking)](../build/reference/c-compile-without-linking.md).) Second, run `lib MathFuncsLib.obj` to link the code and create the static library `MathFuncsLib.lib`. (The `lib` command invokes the Library Manager, Lib.exe. For more information, see [LIB Reference](../build/reference/lib-reference.md).)
@@ -76,44 +85,54 @@ An understanding of the fundamentals of the C++ language.
7685

7786
1. On the menu bar, choose **File** > **New** > **Project**.
7887

79-
2. In the left pane of the **New Project** dialog box, expand **Installed, Visual C++**, and then select **Windows Desktop**.
88+
1. In the left pane of the **New Project** dialog box, expand **Installed** > **Visual C++**, and then select **Windows Desktop**. In the center pane, select **Windows Desktop Wizard**.
89+
90+
> [!NOTE]
91+
> For versions of Visual Studio older than 2017, in the **New Project** dialog box, expand **Installed** > **Templates** > **Visual C++**, and then select **Win32**. In the center pane, select **Win32 Console Application**.
92+
93+
1. Specify a name for the project—for example, *MyExecRefsLib*—in the **Name** box. In the drop-down list next to **Solution**, select **Add to Solution**. This adds the new project to the solution that contains the static library. Choose the **OK** button.
94+
95+
- For Visual Studio 2017,
96+
97+
1. Under **Application type**, select **Console Application (.exe)**.
98+
99+
1. Under **Additioal Options**, un-check the **Precompiled header** check box.
80100

81-
3. In the center pane, select **Windows Desktop Wizard**.
101+
1. Choose **OK** to create the project.
82102

83-
4. Specify a name for the project—for example, *MyExecRefsLib*—in the **Name** box. In the drop-down list next to **Solution**, select **Add to Solution**. This adds the new project to the solution that contains the static library. Choose the **OK** button.
84-
5. Under **Application type**, select **Console Application (.exe)**.
103+
- For versions of Visual Studio older than 2017,
85104

86-
6. Under **Additioal Options**, un-check the **Precompiled header** check box.
105+
1. Click **Next**.
87106

88-
7. Choose **OK** to create the project.
107+
1. Make sure **Console application** is selected. Then check the **Empty Project** box and choose **Finish**.
89108

90109
## <a name="UseLibInApp"></a> Using the functionality from the static library in the app
91110

92111
### To use the functionality from the static library in the app
93112

94113
1. After you create a console app, an empty program is created for you. The name for the source file is the same as the name that you chose earlier. In this example, it's named `MyExecRefsLib.cpp`.
95114

96-
2. Before you can use the math routines in the static library, you must reference it. To do this, open the shortcut menu for the **MyExecRefsLib** project in **Solution Explorer**, and then choose **Add** > **Reference**.
115+
1. Before you can use the math routines in the static library, you must reference it. To do this, open the shortcut menu for the **MyExecRefsLib** project in **Solution Explorer**, and then choose **Add** > **Reference**.
97116

98-
3. The **Add Reference** dialog box lists the libraries that you can reference. The **Projects** tab lists the projects in the current solution and any libraries that they contain. On the **Projects** tab, select the **MathFuncsLib** check box, and then choose the **OK** button.
117+
1. The **Add Reference** dialog box lists the libraries that you can reference. The **Projects** tab lists the projects in the current solution and any libraries that they contain. On the **Projects** tab, select the **MathFuncsLib** check box, and then choose the **OK** button.
99118

100-
4. To reference the `MathFuncsLib.h` header file, you must modify the included directories path. In the **Property Pages** dialog box for **MyExecRefsLib**, expand the **Configuration Properties** node, expand the **C/C++** node, and then select **General**. Next to **Additional Include Directories**, specify the path of the **MathFuncsLib** directory or browse for it.
119+
1. To reference the `MathFuncsLib.h` header file, you must modify the included directories path. In the **Property Pages** dialog box for **MyExecRefsLib**, expand the **Configuration Properties** node, expand the **C/C++** node, and then select **General**. Next to **Additional Include Directories**, specify the path of the **MathFuncsLib** directory or browse for it.
101120

102121
To browse for the directory path, open the property value drop-down list, and then choose **Edit**. In the **Additional Include Directories** dialog box, in the text box, select a blank line and then choose the ellipsis button (**...**) at the end of the line. In the **Select Directory** dialog box, select the **MathFuncsLib** directory and then choose **Select Folder** button to save your selection and close the dialog box. In the **Additional Include Directories** dialog box, choose the **OK** button, and then in the **Property Pages** dialog box, choose the **OK** button to save your changes to the project.
103122

104-
5. You can now use the `MyMathFuncs` class in this app. To do this, replace the contents of `MyExecRefsLib.cpp` with this code:
123+
1. You can now use the `MyMathFuncs` class in this app. To do this, replace the contents of `MyExecRefsLib.cpp` with this code:
105124

106125
[!code-cpp[NVC_Walkthrough_Create_Static_Lib#120](../windows/codesnippet/CPP/walkthrough-creating-and-using-a-static-library-cpp_3.cpp)]
107126

108-
6. Build the executable by choosing **Build** > **Build Solution** on the menu bar.
127+
1. Build the executable by choosing **Build** > **Build Solution** on the menu bar.
109128

110129
## <a name="RunApp"></a> Running the app
111130

112131
### To run the app
113132

114133
1. Make sure that **MyExecRefsLib** is selected as the default project by opening the shortcut menu for **MyExecRefsLib** in **Solution Explorer**, and then choosing **Set as StartUp Project**.
115134

116-
2. To run the project, on the menu bar, choose **Debug** > **Start Without Debugging**. The output should resemble this:
135+
1. To run the project, on the menu bar, choose **Debug** > **Start Without Debugging**. The output should resemble this:
117136

118137
```Output
119138
a + b = 106.4
@@ -125,4 +144,4 @@ An understanding of the fundamentals of the C++ language.
125144
## See Also
126145
127146
[Walkthrough: Creating and Using a Dynamic Link Library (C++)](../build/walkthrough-creating-and-using-a-dynamic-link-library-cpp.md)<br/>
128-
[Desktop Applications (Visual C++)](../windows/desktop-applications-visual-cpp.md)
147+
[Desktop Applications (Visual C++)](../windows/desktop-applications-visual-cpp.md)<br/>

docs/windows/walkthrough-creating-windows-desktop-applications-cpp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Walkthrough: Create a traditional Windows Desktop application (C++) | Microsoft Docs"
33
ms.custom: "get-started-article"
4-
ms.date: "06/12/2018"
4+
ms.date: "09/18/2018"
55
ms.technology: ["cpp-windows"]
66
ms.topic: "conceptual"
77
dev_langs: ["C++"]
@@ -107,7 +107,7 @@ Next, you'll learn how to create the code for a Windows desktop application in V
107107
For information about the parameters and return value of this function, see [WinMain entry point](https://msdn.microsoft.com/library/windows/desktop/ms633559).
108108
109109
> [!NOTE]
110-
> What are all those extra words, such as `CALLBACK`, or `HINSTANCE`, or `_In_`? The traditional Windows API uses typedefs and preprocessor macros extensively to abstract away some of the details of types and platform-specific code, such as calling conventions, **__declspec** declarations, and compiler pragmas. In Visual Studio, you can use the IntelliSense [Quick Info](/visualstudio/ide/using-intellisense#quick-info) feature to see what these typedefs and macros define. Hover your mouse over the word of interest, or select it and press ctrl-K, ctrl-I for a small pop-up window that contains the definition. For more information, see [Using IntelliSense](/visualstudio/ide/using-intellisense). Parameters and return types often use *SAL Annotations* to help you catch programming errors. For more information, see [Using SAL Annotations to Reduce C/C++ Code Defects](/visualstudio/code-quality/using-sal-annotations-to-reduce-c-cpp-code-defects).
110+
> What are all those extra words, such as `CALLBACK`, or `HINSTANCE`, or `_In_`? The traditional Windows API uses typedefs and preprocessor macros extensively to abstract away some of the details of types and platform-specific code, such as calling conventions, **__declspec** declarations, and compiler pragmas. In Visual Studio, you can use the IntelliSense [Quick Info](/visualstudio/ide/using-intellisense#quick-info) feature to see what these typedefs and macros define. Hover your mouse over the word of interest, or select it and press **Ctrl**+**K**, **Ctrl**+**I** for a small pop-up window that contains the definition. For more information, see [Using IntelliSense](/visualstudio/ide/using-intellisense). Parameters and return types often use *SAL Annotations* to help you catch programming errors. For more information, see [Using SAL Annotations to Reduce C/C++ Code Defects](/visualstudio/code-quality/using-sal-annotations-to-reduce-c-cpp-code-defects).
111111
112112
1. Windows desktop programs require &lt;windows.h>. &lt;tchar.h> defines the `TCHAR` macro, which resolves ultimately to **wchar_t** if the UNICODE symbol is defined in your project, otherwise it resolves to **char**. If you always build with UNICODE enabled, you don't need TCHAR and can just use **wchar_t** directly.
113113

0 commit comments

Comments
 (0)