You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# C/C++ projects and build systems in Visual Studio
10
10
11
-
You can use Visual Studio to edit, compile and build any C++ code base with full IntelliSense support without having to convert that code into a Visual Studio project or compile with the MSVC toolset. For example, you can edit a cross-platform CMake project in Visual Studio on a Windows machine, then compile it for Linux using g++ on a remote Linux machine.
11
+
You can use Visual Studio to edit, compile, and build any C++ code base with full IntelliSense support without having to convert that code into a Visual Studio project or compile with the MSVC toolset. For example, you can edit a cross-platform CMake project in Visual Studio on a Windows machine, then compile it for Linux using g++ on a remote Linux machine.
12
12
13
13
## C++ compilation
14
14
@@ -22,25 +22,25 @@ Basic C++ compilation involves three main steps:
22
22
23
23
## The MSVC toolset
24
24
25
-
The Microsoft C++ compiler, linker, standard libraries, and related utilities comprise the MSVC compiler toolset (also called a toolchain or "build tools"). These are included in Visual Studio. You can also download and use the toolset as a standalone package for free from the [Build Tools for Visual Studio 2019 download location](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019).
25
+
The Microsoft C++ compiler, linker, standard libraries, and related utilities make up the MSVC compiler toolset (also called a toolchain or "build tools"). These are included in Visual Studio. You can also download and use the toolset as a free standalone package from [Build Tools for Visual Studio 2019 download](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019).
26
26
27
27
You can build simple programs by invoking the MSVC compiler (cl.exe) directly from the command line. The following command accepts a single source code file, and invokes cl.exe to build an executable called *hello.exe*:
28
28
29
29
```cmd
30
30
cl /EHsc hello.cpp
31
31
```
32
32
33
-
Note that here the compiler (cl.exe) automatically invokes the C++ preprocessor and the linker to produce the final output file. For more information, see [Building on the command line](building-on-the-command-line.md).
33
+
Here the compiler (cl.exe) automatically invokes the C++ preprocessor and the linker to produce the final output file. For more information, see [Building on the command line](building-on-the-command-line.md).
34
34
35
35
## Build systems and projects
36
36
37
-
Most real-world programs use some kind of *build system* to manage complexities of compiling multiple source files for multiple configurations (i.e. debug vs. release), multiple platforms (x86, x64, ARM, and so on), custom build steps, and even multiple executables that must be compiled in a certain order. You make settings in a build configuration file(s), and the build system accepts that file as input before it invoke the compiler. The set of source code files and build configuration files needed to build an executable file is called a *project*.
37
+
Most real-world programs use some kind of *build system* to manage complexities of compiling multiple source files for multiple configurations (debug vs. release), multiple platforms (x86, x64, ARM, and so on), custom build steps, and even multiple executables that must be compiled in a certain order. You make settings in a build configuration file(s), and the build system accepts that file as input before it invoke the compiler. The set of source code files and build configuration files needed to build an executable file is called a *project*.
38
38
39
39
The following list shows various options for Visual Studio Projects - C++:
40
40
41
41
- create a Visual Studio project by using the Visual Studio IDE and configure it by using property pages. Visual Studio projects produce programs that run on Windows. For an overview, see [Compiling and Building](/visualstudio/ide/compiling-and-building-in-visual-studio) in the Visual Studio documentation.
42
42
43
-
- open a folder that contains a CMakeLists.txt file. CMake support is integrated into Visual Studio. You can use the IDE to edit, test and debug without modifying the CMake files in any way. This enables you to work in the same CMake project as others who might be using different editors. CMake is the recommended approach for cross-platform development. For more information, see [CMake projects](cmake-projects-in-visual-studio.md).
43
+
- open a folder that contains a CMakeLists.txt file. CMake support is integrated into Visual Studio. You can use the IDE to edit, test, and debug without modifying the CMake files in any way. This enables you to work in the same CMake project as others who might be using different editors. CMake is the recommended approach for cross-platform development. For more information, see [CMake projects](cmake-projects-in-visual-studio.md).
44
44
45
45
- open a loose folder of source files with no project file. Visual Studio will use heuristics to build the files. This is an easy way to compile and run small console applications. For more information, see [Open Folder projects](open-folder-projects-cpp.md).
46
46
@@ -50,45 +50,45 @@ The following list shows various options for Visual Studio Projects - C++:
50
50
51
51
## MSBuild from the command line
52
52
53
-
You can invoke MSBuild from the command line by passing it a .vcxproj file along with command-line options. This approach requires a good understanding of MSBuild, and is recommended only when absolutely necessary. For more information, see [MSBuild](msbuild-visual-cpp.md).
53
+
You can invoke MSBuild from the command line by passing it a .vcxproj file along with command-line options. This approach requires a good understanding of MSBuild, and is recommended only when necessary. For more information, see [MSBuild](msbuild-visual-cpp.md).
54
54
55
55
## In This Section
56
56
57
-
[Visual Studio projects](creating-and-managing-visual-cpp-projects.md)
57
+
[Visual Studio projects](creating-and-managing-visual-cpp-projects.md)\
58
58
How to create, configure, and build C++ projects in Visual Studio using its native build system (MSBuild).
@@ -121,7 +121,7 @@ The following keywords and special identifiers are recognized by the Microsoft C
121
121
122
122
<sup>5</sup> For compatibility with previous versions, these keywords are available both with two leading underscores and a single leading underscore when Microsoft extensions are enabled.
123
123
124
-
<sup>6</sup> When <assert.h> is not included, the Microsoft Visual C compiler maps **`static_assert`** to the C11 **`_Static_assert`** keyword.
124
+
<sup>6</sup> If you don't include <assert.h>, the Microsoft Visual C compiler maps **`static_assert`** to the C11 **`_Static_assert`** keyword.
125
125
126
126
Microsoft extensions are enabled by default. To assist in creating portable code, you can disable Microsoft extensions by specifying the [/Za \(Disable language extensions)](../build/reference/za-ze-disable-language-extensions.md) option during compilation. When you use this option, some Microsoft-specific keywords are disabled.
title: "_Noreturn keyword and noreturn macro (C11)"
3
+
description: "Describes the `_Noreturn` keyword and `noreturn` macro."
4
+
ms.date: 10/16/2020
5
+
f1_keywords: ["_Noreturn_c", "noreturn"]
6
+
helpviewer_keywords: ["keywords [C]"]
7
+
---
8
+
9
+
# `_Noreturn` keyword and `noreturn` macro (C11)
10
+
11
+
The `_Noreturn` keyword was introduced in C11. It tells the compiler that the function it's applied to doesn't return. The compiler knows that the code following a call to a `_Noreturn` function is unreachable.
12
+
13
+
A convenience macro, `noreturn`, provided in <stdnoreturn.h>, maps to the `_Noreturn` keyword.
14
+
15
+
The primary benefits for using `_Noreturn` (or the equivalent `noreturn`) are making the intention of the function clear in the code for future readers, and detecting unintentionally unreachable code.
16
+
17
+
## Example using `noreturn` macro and `_Noreturn `keyword
18
+
19
+
The following example demonstrates the `_Noreturn` keyword and the equivalent `noreturn` macro.
20
+
21
+
IntelliSense may generate a spurious error, `E0065`, if you use the macro `noreturn` that you can ignore. It doesn't prevent you from running the sample.
22
+
23
+
```C
24
+
// Compile with Warning Level4 (/W4) and /std:c11
25
+
#include<stdio.h>
26
+
#include<stdlib.h>
27
+
#include<stdnoreturn.h>
28
+
29
+
noreturn voidfatal_error(void)
30
+
{
31
+
exit(3);
32
+
}
33
+
34
+
_Noreturn void not_coming_back(void)
35
+
{
36
+
puts("There's no coming back");
37
+
fatal_error();
38
+
return; // warning C4645 - function declared with noreturn has a return statement
39
+
}
40
+
41
+
void done(void)
42
+
{
43
+
puts("We'll never get here");
44
+
}
45
+
46
+
int main(void)
47
+
{
48
+
not_coming_back();
49
+
done(); // warning c4702 - unreachable code
50
+
51
+
return 0;
52
+
}
53
+
```
54
+
55
+
## Requirements
56
+
57
+
|Macro|Required header|
58
+
|-------------|---------------------|
59
+
|**`noreturn`**|\<stdnoreturn.h>|
60
+
61
+
## See also
62
+
63
+
[/std (Specify language standard version)](../build/reference/std-specify-language-standard-version.md)\
description: "Microsoft C/C++ compiler warning C4388, its causes and resolution."
4
+
ms.date: 10/16/2020
5
+
f1_keywords: ["C4388"]
6
+
helpviewer_keywords: ["C4388"]
7
+
---
8
+
# Compiler Warning (level 4) C4388
9
+
10
+
> '*token*' : signed/unsigned mismatch
11
+
12
+
Using the *token* operator to compare a **`signed`** and a larger **`unsigned`** number required the compiler to convert the **`signed`** value to the larger **`unsigned`** type.
13
+
14
+
## Remarks
15
+
16
+
One way to fix this warning is if you cast one of the two types when you compare **`signed`** and larger **`unsigned`** types.
17
+
18
+
This warning is off by default. You can use [/Wall](../../build/reference/compiler-option-warning-level.md) or **`/w44388`** to enable it on the command line as a level 4 warning. Or, use [`#pragma warning(default:4388)`](../../preprocessor/warning.md) in your source file. For more information, see [Compiler warnings that are off by default](../../preprocessor/compiler-warnings-that-are-off-by-default.md).
19
+
20
+
## Example
21
+
22
+
This sample generates C4388 and shows how to fix it:
description: "Microsoft C/C++ compiler warning C4018, its causes and resolution."
4
+
ms.date: 10/16/2020
4
5
f1_keywords: ["C4018"]
5
6
helpviewer_keywords: ["C4018"]
6
-
ms.assetid: 6e8cbb04-d914-4319-b431-cbc2fbe40eb1
7
7
---
8
8
# Compiler Warning (level 3) C4018
9
9
10
-
'expression' : signed/unsigned mismatch
10
+
> '*token*' : signed/unsigned mismatch
11
11
12
-
Comparing a signed and unsigned number required the compiler to convert the signed value to unsigned.
12
+
Using the *token* operator to compare **`signed`** and **`unsigned`** numbers required the compiler to convert the **`signed`** value to **`unsigned`**.
13
13
14
-
This warning may be fixed if you cast one of the two types when testing signed and unsigned types.
14
+
## Remarks
15
15
16
-
The following sample generates C4018:
16
+
One way to fix this warning is if you cast one of the two types when you compare **`signed`** and **`unsigned`** types.
17
+
18
+
## Example
19
+
20
+
This sample generates C4018 and shows how to fix it:
0 commit comments