Skip to content

Commit d9ebc99

Browse files
authored
Merge branch 'master' into mikejo-cpp
2 parents 5ab369d + f34154c commit d9ebc99

File tree

129 files changed

+506
-400
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+506
-400
lines changed

docs/atl/reference/iatlautothreadmodule-class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ms.custom: ""
44
ms.date: "11/04/2016"
55
ms.reviewer: ""
66
ms.suite: ""
7-
ms.technology: ["devlang-cpp"]
7+
ms.technology: ["cpp-windows"]
88
ms.tgt_pltfrm: ""
99
ms.topic: "reference"
1010
f1_keywords: ["IAtlAutoThreadModule", "atlbase/ATL::IAtlAutoThreadModule"]

docs/build/reference/TOC.md

Lines changed: 272 additions & 271 deletions
Large diffs are not rendered by default.

docs/build/reference/zc-alignednew.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
---
2+
title: "/Zc:alignedNew (C++17 over-aligned allocation) | Microsoft Docs"
3+
ms.date: "12/14/2017"
4+
ms.technology: ["cpp-tools"]
5+
ms.topic: "article"
6+
f1_keywords: ["/Zc:alignedNew"]
7+
dev_langs: ["C++"]
8+
helpviewer_keywords: ["/Zc:alignedNew", "Zc:alignedNew", "-Zc:alignedNew"]
9+
author: "corob-msft"
10+
ms.author: "corob"
11+
manager: "ghogen"
12+
---
13+
# /Zc:alignedNew (C++17 over-aligned allocation)
14+
15+
Enable support for C++17 over-aligned **new**, dynamic memory allocation aligned on boundaries greater than the default for the maximum-sized standard aligned type, **max\_align\_t**.
16+
17+
## Syntax
18+
19+
> **/Zc:alignedNew**[-]
20+
21+
## Remarks
22+
23+
Visual Studio version 15.5 enables compiler and library support for C++17 standard over-aligned dynamic memory allocation. When the **/Zc:alignedNew** option is specified, a dynamic allocation such as `new Example;` respects the alignment of *Example* even when it’s greater than `max_align_t`, the largest alignment required for any fundamental type. When the alignment of the allocated type is no more than that guaranteed by the original operator **new**, available as the value of the predefined macro **\_\_STDCPP\_DEFAULT\_NEW\_ALIGNMENT\_\_**, the statement `new Example;` results in a call to `::operator new(size_t)` as it did in C++14. When the alignment is greater than **\_\_STDCPP\_DEFAULT\_NEW\_ALIGNMENT\_\_**, the implementation instead obtains the memory by using `::operator new(size_t, align_val_t)`. Similarly, deletion of over-aligned types invokes `::operator delete(void*, align_val_t)` or the sized delete signature `::operator delete(void*, size_t, align_val_t)`.
24+
25+
The **/Zc:alignedNew** option is only available when [/std:c++17](std-specify-language-standard-version.md) or [/std:c++latest](std-specify-language-standard-version.md) is enabled. Under **/std:c++17** or **/std:c++latest**, **/Zc:alignedNew** is enabled by default to conform to the ISO C++17 standard. If the only reason you implement operator **new** and **delete** is to support over-aligned allocations, you may no longer need this code in C++17 mode. To turn this option off and revert to the C++14 behavior of **new** and **delete** when **/std::c++17** or **/std:c++latest** is specified, specify **/Zc:alignedNew-**. If you implement operator **new** and **delete** but you are not ready to implement the over-aligned operator **new** and **delete** overloads that have the `align_val_t` parameter, use the **/Zc:alignedNew-** option to prevent the compiler and Standard Library from generating calls to the over-aligned overloads.
26+
27+
## Example
28+
29+
This sample shows how operator **new** and operator **delete** behave when the **/Zc:alignedNew** option is set.
30+
31+
```cpp
32+
// alignedNew.cpp
33+
// Compile by using: cl /EHsc /std:c++17 /W4 alignedNew.cpp
34+
#include <iostream>
35+
#include <malloc.h>
36+
#include <new>
37+
38+
// "old" unaligned overloads
39+
void* operator new(std::size_t size) {
40+
auto ptr = malloc(size);
41+
std::cout << "unaligned new(" << size << ") = " << ptr << '\n';
42+
return ptr ? ptr : throw std::bad_alloc{};
43+
}
44+
45+
void operator delete(void* ptr, std::size_t size) {
46+
std::cout << "unaligned sized delete(" << ptr << ", " << size << ")\n";
47+
free(ptr);
48+
}
49+
50+
void operator delete(void* ptr) {
51+
std::cout << "unaligned unsized delete(" << ptr << ")\n";
52+
free(ptr);
53+
}
54+
55+
// "new" over-aligned overloads
56+
void* operator new(std::size_t size, std::align_val_t align) {
57+
auto ptr = _aligned_malloc(size, static_cast<std::size_t>(align));
58+
std::cout << "aligned new(" << size << ", " <<
59+
static_cast<std::size_t>(align) << ") = " << ptr << '\n';
60+
return ptr ? ptr : throw std::bad_alloc{};
61+
}
62+
63+
void operator delete(void* ptr, std::size_t size, std::align_val_t align) {
64+
std::cout << "aligned sized delete(" << ptr << ", " << size <<
65+
", " << static_cast<std::size_t>(align) << ")\n";
66+
_aligned_free(ptr);
67+
}
68+
69+
void operator delete(void* ptr, std::align_val_t align) {
70+
std::cout << "aligned unsized delete(" << ptr <<
71+
", " << static_cast<std::size_t>(align) << ")\n";
72+
_aligned_free(ptr);
73+
}
74+
75+
struct alignas(256) OverAligned {}; // warning C4324, structure is padded
76+
77+
int main() {
78+
delete new int;
79+
delete new OverAligned;
80+
}
81+
```
82+
83+
This output is typical for 32-bit builds. The pointer values vary based on where your application runs in memory.
84+
85+
```Output
86+
unaligned new(4) = 009FD0D0
87+
unaligned sized delete(009FD0D0, 4)
88+
aligned new(256, 256) = 009FE800
89+
aligned sized delete(009FE800, 256, 256)
90+
```
91+
92+
For information about conformance issues in Visual C++, see [Nonstandard Behavior](../../cpp/nonstandard-behavior.md).
93+
94+
### To set this compiler option in the Visual Studio development environment
95+
96+
1. Open the project's **Property Pages** dialog box. For details, see [Working with Project Properties](../../ide/working-with-project-properties.md).
97+
98+
1. Select the **Command Line** property page in the **C/C++** folder.
99+
100+
1. Modify the **Additional Options** property to include **/Zc:alignedNew** or **/Zc:alignedNew-** and then choose **OK**.
101+
102+
## See also
103+
104+
[/Zc (Conformance)](../../build/reference/zc-conformance.md)

docs/build/reference/zc-conformance.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ These are the `/Zc` compiler options:
3333

3434
|Option|Behavior|
3535
|---|---|
36+
|[alignedNew\[-\]](zc-alignednew.md)|Enable C++17 over-aligned dynamic allocation (on by default in C++17).|
3637
|[auto\[-\]](zc-auto-deduce-variable-type.md)|Enforce the new Standard C++ meaning for `auto` (on by default).|
3738
|[externConstexpr\[-\]](zc-externconstexpr.md)|Enable external linkage for `constexpr` variables (off by default).|
3839
|[forScope\[-\]](zc-forscope-force-conformance-in-for-loop-scope.md)|Enforce Standard C++ `for` scoping rules (on by default).|

docs/data/data-access-in-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Connect to Azure SQL Database from C or C++ applications.
4343
[ODBC Driver 13.1 for SQL Server - Windows Released](https://blogs.msdn.microsoft.com/sqlnativeclient/2016/08/01/announcing-the-odbc-driver-13-1-for-sql-server)
4444
The latest ODBC driver provides robust data access to Microsoft SQL Server 2016 Microsoft Azure SQL Database for C/C++ based applications. Provides support for features including always encrypted, Azure Active Directory, and AlwaysOn Availability Groups. Also available for MacOS and Linux.
4545

46-
[SQL Server Native Client](https://msdn.microsoft.com/library/ms130892.aspx)
46+
[SQL Server Native Client](/sql/relational-databases/native-client/sql-server-native-client-programming)
4747
SQL Server Native Client is a stand-alone data access application programming interface (API), used for both OLE DB and ODBC, that supports SQL Server 2005 through SQL Server 2014. New applications should use the ODBC Driver 13.1 for SQL Server.
4848

4949
[Microsoft Azure C and C++ Developer Center](https://azure.microsoft.com/develop/cpp/)

docs/data/data-access-programming-mfc-atl.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ ms.workload: ["cplusplus", "data-storage"]
1919
# Data Access Programming (MFC/ATL)
2020
Over the years, Visual C++ has provided several ways to work with databases. In 2011 Microsoft announced that it is aligning on ODBC as the preferred technology for accessing SQL Server products from native code. ODBC is an industry standard, and by using it you gain maximum portability of your code over multiple platforms and data sources. Most SQL database products and many NoSQL products support ODBC. You can use ODBC directly by calling the low-level ODBC APIs, or you can use the MFC ODBC wrapper classes, or a third-party C++ wrapper library.
2121

22-
OLE DB is a low-level, high-performance API based on the COM specification, and is only supported on Windows. Use OLE DB if your program is accessing [linked servers](https://msdn.microsoft.com/library/ms188279.aspx). ATL provides OLE DB templates that make it easier to create custom OLE DB providers and consumers. The most recent version of OLE DB shipped in SQL Native Client 11.
22+
OLE DB is a low-level, high-performance API based on the COM specification, and is only supported on Windows. Use OLE DB if your program is accessing [linked servers](/sql/relational-databases/linked-servers/linked-servers-database-engine). ATL provides OLE DB templates that make it easier to create custom OLE DB providers and consumers. The most recent version of OLE DB shipped in SQL Native Client 11.
2323

2424
If your legacy application uses OLE DB or the higher-level ADO interface to connect to SQL Server, and you are not accessing linked servers, you should consider migrating to ODBC in the near future. If you do not require cross-platform portability or the latest SQL Server features, you can possibly use the Microsoft OLE DB Provider for ODBC (MSDASQL). MSDASQL allows applications that are built on OLE DB and ADO (which uses OLEDB internally) to access data sources through an ODBC driver. As with any translation layer, MSDASQL can impact database performace. You should test to determine whether the impact is signifant for your application. MSDASQL ships with the Windows operating system, and Windows Server 2008 & Windows Vista SP1 are the first Windows releases to include a 64-bit version of the technology.
2525

26-
The SQL Native Client component (SNAC), which packages OLE DB and ODBC drivers in a single DLL, is deprecated for ODBC applications. The SQL Server 2012 version of SNAC (SQLNCLI11.DLL) ships with SQL Server 2016 because other SQL Server components depend on it. However, new C++ applications that connect to SQL Server or Azure SQL Database via ODBC should use [the most recent ODBC driver](https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server). For more information, see [SQL Server Native Client Programming](https://msdn.microsoft.com/en-us/library/ms130892.aspx)
26+
The SQL Native Client component (SNAC), which packages OLE DB and ODBC drivers in a single DLL, is deprecated for ODBC applications. The SQL Server 2012 version of SNAC (SQLNCLI11.DLL) ships with SQL Server 2016 because other SQL Server components depend on it. However, new C++ applications that connect to SQL Server or Azure SQL Database via ODBC should use [the most recent ODBC driver](https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server). For more information, see [SQL Server Native Client Programming](/sql/relational-databases/native-client/sql-server-native-client-programming)
2727

2828
If you use C++/CLI, you can continue to use ADO.NET as always. For more information, see [Data Access Using ADO.NET (C++/CLI)](../dotnet/data-access-using-adonet-cpp-cli.md), and [Accessing data in Visual Studio](/visualstudio/data-tools/accessing-data-in-visual-studio).
2929

docs/dotnet/how-to-consume-a-csharp-indexer-cpp-cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Visual C++ does not contain indexers; it has indexed properties. To consume a C#
2121

2222
For more information about indexers, see:
2323

24-
- [Indexers](https://msdn.microsoft.com/library/6x16t2tx.aspx)
24+
- [Indexers](/dotnet/csharp/programming-guide/indexers/index)
2525

2626
## Example
2727
The following C# program defines an indexer.

docs/mfc/creating-a-ctoolbarctrl-object.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ms.author: "mblome"
1717
manager: "ghogen"
1818
---
1919
# Creating a CToolBarCtrl Object
20-
[CToolBarCtrl](../mfc/reference/ctoolbarctrl-class.md) objects contain several internal data structures — a list of button image bitmaps, a list of button label strings, and a list of `TBBUTTON` structures — that associate an image and/or string with the position, style, state, and command ID of the button. Each of the elements of these data structures is referred to by a zero-based index. Before you can use a `CToolBarCtrl` object, you must set up these data structures. For a list of the data structures, see [Toolbar Controls](https://msdn.microsoft.com/library/47xcww9x.aspx) in the Windows SDK. The list of strings can only be used for button labels; you cannot retrieve strings from the toolbar.
20+
[CToolBarCtrl](../mfc/reference/ctoolbarctrl-class.md) objects contain several internal data structures — a list of button image bitmaps, a list of button label strings, and a list of `TBBUTTON` structures — that associate an image and/or string with the position, style, state, and command ID of the button. Each of the elements of these data structures is referred to by a zero-based index. Before you can use a `CToolBarCtrl` object, you must set up these data structures. For a list of the data structures, see [Toolbar Controls](controls-mfc.md) in the Windows SDK. The list of strings can only be used for button labels; you cannot retrieve strings from the toolbar.
2121

2222
To use a `CToolBarCtrl` object, you will typically follow these steps:
2323

docs/mfc/reference/cgopherfile-class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ CGopherFile(
8787
A handle to the current Internet session.
8888

8989
`pstrLocator`
90-
A pointer to a string used to locate the gopher server. See [Gopher Sessions](https://msdn.microsoft.com/library/24wz8xze.aspx) for more information about gopher locators.
90+
A pointer to a string used to locate the gopher server. See [Gopher Sessions](cgopherlocator-class.md) for more information about gopher locators.
9191

9292
*dwLocLen*
9393
A DWORD containing the number of bytes in `pstrLocator`.

docs/mfc/reference/icommandsource-interface.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ A handle to the command handler method.
6868

6969
### Remarks
7070
This method adds the command handler cmdHandler to the command source object and maps the handler to cmdID.
71-
See [How to: Add Command Routing to the Windows Forms Control](https://msdn.microsoft.com/library/y33d8624.aspx) for an example of how to use AddCommandHandler.
71+
See [How to: Add Command Routing to the Windows Forms Control](../../dotnet/how-to-add-command-routing-to-the-windows-forms-control.md) for an example of how to use AddCommandHandler.
7272

7373
## <a name="addcommandrangehandler"></a> ICommandSource::AddCommandRangeHandler
7474

docs/porting/porting-data-applications.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ manager: "ghogen"
1919
# Porting Data Applications
2020
Over the years, Visual C++ has provided several ways to work with databases. In 2011 Microsoft announced that it is aligning on ODBC as the preferred technology for accessing SQL Server products from native code. ODBC is an industry standard, and by using it you gain maximum portability of your code over multiple platforms and data sources. Most SQL database products and many NoSQL products support ODBC. You can use ODBC directly by calling the low-level ODBC APIs, or you can use the MFC ODBC wrapper classes, or a third-party C++ wrapper library.
2121

22-
OLE DB is a low-level, high-performance API based on the COM specification, and is only supported on Windows. Use OLE DB if your program is accessing [linked servers](https://msdn.microsoft.com/library/ms188279.aspx). ATL provides OLE DB templates that make it easier to create custom OLE DB providers and consumers. The most recent version of OLE DB shipped in SQL Native Client 11.
22+
OLE DB is a low-level, high-performance API based on the COM specification, and is only supported on Windows. Use OLE DB if your program is accessing [linked servers](/sql/relational-databases/linked-servers/linked-servers-database-engine). ATL provides OLE DB templates that make it easier to create custom OLE DB providers and consumers. The most recent version of OLE DB shipped in SQL Native Client 11.
2323

2424
If your legacy application uses OLE DB or the higher-level ADO interface to connect to SQL Server, and you are not accessing linked servers, you should consider migrating to ODBC in the near future. If you do not require cross-platform portability or the latest SQL Server features, you can possibly use the Microsoft OLE DB Provider for ODBC (MSDASQL). MSDASQL allows applications that are built on OLE DB and ADO (which uses OLEDB internally) to access data sources through an ODBC driver. As with any translation layer, MSDASQL can impact database performace. You should test to determine whether the impact is signifant for your application. MSDASQL ships with the Windows operating system, and Windows Server 2008 & Windows Vista SP1 are the first Windows releases to include a 64-bit version of the technology.
2525

26-
The SQL Native Client component (SNAC), which packages OLE DB and ODBC drivers in a single DLL, is deprecated for ODBC applications. The SQL Server 2012 version of SNAC (SQLNCLI11.DLL) ships with SQL Server 2016 because other SQL Server components depend on it. However, new C++ applications that connect to SQL Server or Azure SQL Database via ODBC should use [the most recent ODBC driver](https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server). For more information, see [SQL Server Native Client Programming](https://msdn.microsoft.com/en-us/library/ms130892.aspx)
26+
The SQL Native Client component (SNAC), which packages OLE DB and ODBC drivers in a single DLL, is deprecated for ODBC applications. The SQL Server 2012 version of SNAC (SQLNCLI11.DLL) ships with SQL Server 2016 because other SQL Server components depend on it. However, new C++ applications that connect to SQL Server or Azure SQL Database via ODBC should use [the most recent ODBC driver](https://docs.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server). For more information, see [SQL Server Native Client Programming](/sql/relational-databases/native-client/sql-server-native-client-programming)
2727

2828
If you use C++/CLI, you can continue to use ADO.NET as always. For more information, see [Data Access Using ADO.NET (C++/CLI)](../dotnet/data-access-using-adonet-cpp-cli.md), and [Accessing data in Visual Studio](/visualstudio/data-tools/accessing-data-in-visual-studio).
2929

docs/standard-library/bitset-operators.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ basic_ostream<CharType, Traits>& operator<<(
9191
### Remarks
9292
The template function overloads **operator<<**, allowing a bitset to be written out without first converting it into a string. The template function effectively executes:
9393

94-
**ostr** << _ *Right*. [to_string](https://msdn.microsoft.com/library/2f93c55z.aspx) < **CharType**, **Traits**, **allocator**\< **CharType**> > ( )
94+
**ostr** << _ *Right*. [to_string](bitset-class.md) < **CharType**, **Traits**, **allocator**\< **CharType**> > ( )
9595

9696
### Example
9797

@@ -148,7 +148,7 @@ _Istr,
148148
The template function returns the string `_Istr`.
149149
150150
### Remarks
151-
The template function overloads **operator>>** to store in the bitset _ *Right* the value bitset( `str`), where `str` is an object of type [basic_string](https://msdn.microsoft.com/library/syxtdd4f.aspx) < **CharType**, **Traits**, **allocator**\< **CharType**> > **&** extracted from `_Istr`.
151+
The template function overloads **operator>>** to store in the bitset _ *Right* the value bitset( `str`), where `str` is an object of type [basic_string](basic-string-class.md) < **CharType**, **Traits**, **allocator**\< **CharType**> > **&** extracted from `_Istr`.
152152
153153
The template function extracts elements from `_Istr` and inserts them into the bitset until:
154154

0 commit comments

Comments
 (0)