diff --git a/docs/build/image.png b/docs/build/image.png new file mode 100644 index 0000000000..f892839fa3 Binary files /dev/null and b/docs/build/image.png differ diff --git a/docs/build/media/desktop-development-cpp-workload.png b/docs/build/media/desktop-development-cpp-workload.png new file mode 100644 index 0000000000..a321200feb Binary files /dev/null and b/docs/build/media/desktop-development-cpp-workload.png differ diff --git a/docs/build/media/github-copilot-fix-warning-accept.png b/docs/build/media/github-copilot-fix-warning-accept.png new file mode 100644 index 0000000000..bb8f3ded87 Binary files /dev/null and b/docs/build/media/github-copilot-fix-warning-accept.png differ diff --git a/docs/build/media/github-copilot-fix-warning.png b/docs/build/media/github-copilot-fix-warning.png new file mode 100644 index 0000000000..4751bafdf0 Binary files /dev/null and b/docs/build/media/github-copilot-fix-warning.png differ diff --git a/docs/build/media/github-copilot-open-chat.png b/docs/build/media/github-copilot-open-chat.png new file mode 100644 index 0000000000..c89019f9ab Binary files /dev/null and b/docs/build/media/github-copilot-open-chat.png differ diff --git a/docs/build/media/life-exe.png b/docs/build/media/life-exe.png new file mode 100644 index 0000000000..94bad16e7d Binary files /dev/null and b/docs/build/media/life-exe.png differ diff --git a/docs/build/use-github-copilot-create-cpp-console-app.md b/docs/build/use-github-copilot-create-cpp-console-app.md new file mode 100644 index 0000000000..b70ab46038 --- /dev/null +++ b/docs/build/use-github-copilot-create-cpp-console-app.md @@ -0,0 +1,249 @@ +--- +title: Use AI to create a C++ console application in Visual Studio +description: "Learn how to use GitHub Copilot to create a C++ app using Microsoft C++ in Visual Studio." +ms.date: 10/24/2025 +ms.topic: "tutorial" +ms.custom: + - ai-assisted + - copilot-scenario-highlight +--- + +# Use AI to create a C++ console application in Visual Studio + +This tutorial shows you how to use GitHub Copilot to quickly create a C++ console application in Visual Studio. You create a console version of Conway's Game of Life, a classic cellular automaton. + +Conway's Game of Life was devised by mathematician John Conway. It consists of a grid of cells that can be either alive or dead. The game evolves automatically based on simple rules and produces complex, evolving patterns that demonstrate how intricate behavior can emerge from basic mathematical rules. + +GitHub Copilot is an AI-powered coding assistant that helps you write code faster, reduce errors, and explore new solutions. Some benefits of using Copilot when coding in C++: +- Generate entire C++ functions or classes as you type. +- Suggest code completions based on plain-language comments or prompts. +- Get help with complex algorithms, data structures, and standard library usage. +- Learn new APIs and modern C++ patterns through in-context examples. +- Receive context-aware suggestions based on your comments or code. +- Debug errors in your code. +- Simplify and refactor existing code. + +## Prerequisites + +- Visual Studio 2022 or later with the **Desktop development with C++** workload installed. +- GitHub Copilot. For more information, see [Get started with GitHub Copilot](/visualstudio/ide/visual-studio-github-copilot-get-started). + +To verify you have the C++ workload installed: +1. Open Visual Studio Installer +1. Select **Modify** next to your Visual Studio installation +1. Ensure **Desktop development with C++** is checked: + + :::image type="content" source="media/desktop-development-cpp-workload.png" alt-text="Screenshot of the Visual Studio Installer with the Workloads tab selected. Desktop development with c++ is selected."::: + +1. If it isn't installed, select it and choose **Modify**. + +For more information about installing Copilot, see [Manage GitHub Copilot installation and state](/visualstudio/ide/visual-studio-github-copilot-install-and-states). + +## Create a project + +Visual Studio uses *projects* to organize the code for an app, and *solutions* to organize your projects. A project contains all the options, configurations, and rules used to build your apps. It manages the relationship between all the project's files and any external files. To create your app, first, create a new project and solution. + +1. Open Visual Studio and select **Create a new project**. +1. Search for "Console App" and select the **Console App** template for C++. + + :::image type="complex" source="media/vs2019-choose-console-app.png" alt-text="Screenshot of the Create a new project dialog."::: + The Create a new project dialog is shown with the Console App template selected. The template says: Run code in a windows terminal. Prints hello world by default. Has the tags c++, Windows, and Console. + :::image-end::: + +1. Select **Next**. +1. Set the project name to **Life** and choose the location for the project. +1. Select **Create**. +1. Once the project opens, find the `Life.cpp` file in Solution Explorer. +1. Open `Life.cpp` and delete the default "Hello, World!" code to start with a clean slate. + +## Use Copilot to create an app + +You prompt Copilot by describing the functionality you want. In this section, you'll learn how to prompt Copilot to generate an implementation of Conway's Game of Life. + +1. Open the Copilot chat window by selecting the Copilot icon in the toolbar: + + :::image type="content" source="media/github-copilot-open-chat.png" alt-text="Screenshot of the GitHub icon dropdown. Open Chat Window is selected."::: + +1. In the chat window, enter the following prompt: + ```copilot-prompt + Create a C++ console application that implements Conway's Game of Life. The program should: + - Use a 40x20 grid displayed with asterisks (*) for live cells and spaces for dead cells + - Start with a random initial pattern + - Display each generation for 500ms before showing the next + - Allow the user to press any key to exit the program + - Include proper headers and use standard C++ practices + - Clear the console between generations to provide an animation effect + ``` +1. Copilot generates C++ code for Conway's Game of Life. +1. Copy the generated code and paste it into your empty `Life.cpp` file. +1. Build the project by pressing **F6** or selecting **Build > Build Solution**. +1. Run the program by pressing **F5** or **Ctrl+F5**. + +> [!NOTE] +> The exact code generated by Copilot may vary slightly from run to run and model to model, but the core functionality should be consistent. If the generated code doesn't compile immediately, you can ask Copilot to fix any compilation errors. Copilot is powered by AI, so surprises and mistakes are possible. For more information, see [Copilot FAQs](https://aka.ms/copilot-general-use-faqs). + +### Example of typical generated code structure + +Your generated code will likely include these key components: + +- Headers for console manipulation, random number generation, and timing +- A 2D array or vector to represent the game grid +- Functions to initialize the grid, apply Conway's rules, and display the current state +- A main loop that continues until a key is pressed + +Here's an example of the code that Copilot generated using the previous prompt: + +```cpp +// Code generated by GitHub Copilot +#include +#include +#include +#include // for _kbhit and _getch + +using namespace std; + +int step = 0; +const int rows = 20; +const int cols = 40; + +void printGrid(int grid[rows][cols]) +{ + cout << "Step: " << step << endl; + for (int i = 0; i < rows; ++i) + { + for (int j = 0; j < cols; ++j) + { + cout << (grid[i][j] ? '*' : ' '); + } + cout << endl; + } +} + +int countNeighbors(int grid[rows][cols], int x, int y) +{ + int count = 0; + for (int i = -1; i <= 1; ++i) + { + for (int j = -1; j <= 1; ++j) + { + if (i == 0 && j == 0) + { + continue; + } + + int ni = x + i; + int nj = y + j; + if (ni >= 0 && ni < rows && nj >= 0 && nj < cols) + { + count += grid[ni][nj]; + } + } + } + return count; +} + +void updateGrid(int grid[rows][cols]) +{ + int newGrid[rows][cols] = { 0 }; + for (int i = 0; i < rows; ++i) + { + for (int j = 0; j < cols; ++j) + { + int neighbors = countNeighbors(grid, i, j); + if (grid[i][j] == 1) + { + newGrid[i][j] = (neighbors < 2 || neighbors > 3) ? 0 : 1; + } + else + { + newGrid[i][j] = (neighbors == 3) ? 1 : 0; + } + } + } + // Copy newGrid back to grid + for (int i = 0; i < rows; ++i) + { + for (int j = 0; j < cols; ++j) + { + grid[i][j] = newGrid[i][j]; + } + } +} + +int main() +{ + int grid[rows][cols] = { 0 }; + + // Initial configuration (a simple glider) + grid[1][2] = 1; + grid[2][3] = 1; + grid[3][1] = 1; + grid[3][2] = 1; + grid[3][3] = 1; + + while (true) + { + if (_kbhit()) // Check if a key has been pressed + { + _getch(); // Consume the key + break; // Exit the loop + } + printGrid(grid); + updateGrid(grid); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + cout << "\033[H\033[J"; // Clear the screen + step++; + } + + return 0; +} +``` +When you run the application, you should see an animated display of Conway's Game of Life with patterns evolving over time. To exit the program, press a key. + +:::image type="content" source="./media/life-exe.png" alt-text="Screenshot of Conway Life running in a command window, displaying the evolving grid of cells."::: + +In the preceding code example, the code generates a warning: `Return value ignored: '_getch'`. You can ask Copilot to fix it. Select the code editor and press **Alt+/** (Windows) to open the Copilot chat, then enter: + +:::image type="content" source="./media/github-copilot-fix-warning.png" alt-text="Screenshot of the Copilot chat window. The text: Fix warning C6031 is in the chat window."::: + +Copilot suggests a fix to handle the return value properly. To accept the changes, select **Tab**: + +:::image type="content" source="./media/github-copilot-fix-warning-accept.png" alt-text="Screenshot of the Copilot proposed changes. Tab to accept. Alt+Del to discard."::: + +Congratulations! You successfully used GitHub Copilot to create a fully functional Conway's Game of Life console application in C++. You learned how to: + +- Craft an effective prompt to generate C++ code +- Use Copilot's chat interface to create an entire application from scratch +- Fix compilation warnings with AI assistance + +## Improve your prompting skills + +For better results with Copilot, see these prompting resources: + +- [GitHub Copilot documentation](https://docs.github.com/en/copilot) - Official best practices and tips +- [OpenAI's GPT best practices](https://platform.openai.com/docs/guides/prompt-engineering) - General AI prompting techniques +- [Copilot prompting guide](https://github.blog/2023-06-20-how-to-write-better-prompts-for-github-copilot/) - Specific guidance for code generation + +## Troubleshooting + +### Missing console app template + +The **New Project** dialog should show a **Console App** template that has **C++**, **Windows**, and **Console** tags. If you don't see it, it might be filtered out of the list, or it might not be installed. First, check the filter dropdowns at the top of the list of templates. Set them to **C++**, **Windows**, and **Console**. The C++ **Console App** template should appear; otherwise, the **Desktop development with C++** workload isn't installed. + +To install **Desktop development with C++**, you can run the installer right from the **Create a new project** dialog. Choose the **Install more tools and features** link at the bottom of the **Create a new project** dialog, beneath the list of templates. If the **User Account Control** dialog requests permissions, choose **Yes**. In the installer, make sure the **Desktop development with C++** workload is checked. Then choose **Modify** to update your Visual Studio installation. + +### Copilot not responding + +- Ensure you have an active GitHub Copilot subscription. +- Try signing out and back into your GitHub account in Visual Studio + +### Generated code doesn't compile + +- Ask Copilot to fix specific compilation errors by pasting the error message into Copilot chat. +- Try refining your prompt to be more specific about what you want the app to do. + +## Next steps + +- [GitHub Copilot in Visual Studio](/visualstudio/ide/visual-studio-github-copilot-install-and-states) +- [GitHub Copilot documentation](https://docs.github.com/en/copilot) - Dive deeper into AI-assisted development +- [Awesome ChatGPT Prompts](https://github.com/f/awesome-chatgpt-prompts) - Community-driven prompting examples for inspiration \ No newline at end of file diff --git a/docs/build/vscpp-step-0-installation.md b/docs/build/vscpp-step-0-installation.md index 0a5311c1fd..903016883a 100644 --- a/docs/build/vscpp-step-0-installation.md +++ b/docs/build/vscpp-step-0-installation.md @@ -128,7 +128,7 @@ Some benefits of using Copilot for your C++ coding scenarios: - Debug errors in your code. - Simplify and refactor existing code. -To install GitHub Copilot, see [Manage GitHub Copilot installation and state](/visualstudio/ide/visual-studio-github-copilot-install-and-states). +To try GitHub copilot to create a C++ app, follow the instructions in [Use AI to create a C++ console application in Visual Studio](../build/use-github-copilot-create-cpp-console-app.md). ::: moniker-end @@ -225,9 +225,7 @@ You can reduce the installation footprint of Visual Studio on your system drive. ### Step 8 - Start developing 1. After Visual Studio installation is complete, choose the **Launch** button to get started developing with Visual Studio. - 1. On the start window, choose **Create a new project**. - 1. In the search box, enter the type of app you want to create to see a list of available templates. The list of templates depends on the workloads that you chose during installation. To see different templates, choose different workloads. You can also filter your search for a specific programming language by using the **Language** dropdown list. You can filter by using the **Platform** list and the **Project type** list, too. diff --git a/docs/c-runtime-library/reference/ctime-ctime32-ctime64-wctime-wctime32-wctime64.md b/docs/c-runtime-library/reference/ctime-ctime32-ctime64-wctime-wctime32-wctime64.md index 0b2cc7c948..3f03733bda 100644 --- a/docs/c-runtime-library/reference/ctime-ctime32-ctime64-wctime-wctime32-wctime64.md +++ b/docs/c-runtime-library/reference/ctime-ctime32-ctime64-wctime-wctime32-wctime64.md @@ -8,7 +8,6 @@ api_type: ["DLLExport"] topic_type: ["apiref"] f1_keywords: ["_wctime64", "_ctime32", "_tctime", "_wctime", "_wctime32", "_tctime64", "_ctime64", "ctime"] helpviewer_keywords: ["tctime64 function", "_ctime32 function", "ctime32 function", "_wctime function", "wctime64 function", "_tctime64 function", "_tctime32 function", "_ctime64 function", "_wctime64 function", "ctime function", "wctime32 function", "ctime64 function", "_wctime32 function", "_tctime function", "tctime32 function", "tctime function", "wctime function", "time, converting"] -ms.assetid: 2423de37-a35c-4f0a-a378-3116bc120a9d --- # `ctime`, `_ctime32`, `_ctime64`, `_wctime`, `_wctime32`, `_wctime64` @@ -17,10 +16,10 @@ Convert a time value to a string and adjust for local time zone settings. More s ## Syntax ```C -char *ctime( const time_t *sourceTime ); +char *ctime( const time_t *sourceTime ); // See note in remarks section about linkage char *_ctime32( const __time32_t *sourceTime ); char *_ctime64( const __time64_t *sourceTime ); -wchar_t *_wctime( const time_t *sourceTime ); +wchar_t *_wctime( const time_t *sourceTime ); // See note in remarks section about linkage wchar_t *_wctime32( const __time32_t *sourceTime ); wchar_t *_wctime64( const __time64_t *sourceTime ); ``` @@ -62,9 +61,14 @@ These functions validate their parameters. If *`sourceTime`* is a null pointer, By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md). +> [!Note] +> When you use Windows SDK version 10.0.26100.6901 and Visual Studio 2026 or later together, `ctime` and `_wctime` are no longer `static inline` (internal linkage). Instead, they're `inline` (external linkage).\ +> To return to the previous behavior, `#define _STATIC_INLINE_UCRT_FUNCTIONS=1` before including any CRT headers. By default, `_STATIC_INLINE_UCRT_FUNCTIONS` is set to 0.\ +> This change increases UCRT conformance with the C++ standard and improves compatibility with C++ modules. + ### Generic-text routine mappings -| TCHAR.H routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined | +| `TCHAR.H` routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined | |---|---|---|---| | `_tctime` | **`ctime`** | **`ctime`** | **`_wctime`** | | `_tctime32` | **`_ctime32`** | **`_ctime32`** | **`_wctime32`** | @@ -74,12 +78,12 @@ By default, this function's global state is scoped to the application. To change | Routine | Required header | |---|---| -| **`ctime`** | \ | -| **`_ctime32`** | \ | -| **`_ctime64`** | \ | -| **`_wctime`** | \ or \ | -| **`_wctime32`** | \ or \ | -| **`_wctime64`** | \ or \ | +| **`ctime`** | `` | +| **`_ctime32`** | `` | +| **`_ctime64`** | `` | +| **`_wctime`** | `` or `` | +| **`_wctime32`** | `` or `` | +| **`_wctime64`** | `` or `` | For more compatibility information, see [Compatibility](../compatibility.md). diff --git a/docs/c-runtime-library/reference/ctime-s-ctime32-s-ctime64-s-wctime-s-wctime32-s-wctime64-s.md b/docs/c-runtime-library/reference/ctime-s-ctime32-s-ctime64-s-wctime-s-wctime32-s-wctime64-s.md index fcf23eb2ce..12965dc90e 100644 --- a/docs/c-runtime-library/reference/ctime-s-ctime32-s-ctime64-s-wctime-s-wctime32-s-wctime64-s.md +++ b/docs/c-runtime-library/reference/ctime-s-ctime32-s-ctime64-s-wctime-s-wctime32-s-wctime64-s.md @@ -16,7 +16,7 @@ Convert a time value to a string and adjust for local time zone settings. These ## Syntax ```C -errno_t ctime_s( +errno_t ctime_s( // See note in remarks section about linkage char* buffer, size_t numberOfElements, const time_t *sourceTime @@ -31,7 +31,7 @@ errno_t _ctime64_s( size_t numberOfElements, const __time64_t *sourceTime ); -errno_t _wctime_s( +errno_t _wctime_s( // See note in remarks section about linkage wchar_t* buffer, size_t numberOfElements, const time_t *sourceTime @@ -124,6 +124,11 @@ The debug library versions of these functions first fill the buffer with 0xFE. T By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md). +> [!Note] +> When you use Windows SDK version 10.0.26100.6901 and Visual Studio 2026 or later together, `ctime_s` and `_wctime_s` are no longer `static inline` (internal linkage). Instead, they're `inline` (external linkage).\ +> To return to the previous behavior, `#define _STATIC_INLINE_UCRT_FUNCTIONS=1` before including any CRT headers. By default, `_STATIC_INLINE_UCRT_FUNCTIONS` is set to 0.\ +> This change increases UCRT conformance with the C++ standard and improves compatibility with C++ modules. + ### Generic-text routine mappings | TCHAR.H routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined | diff --git a/docs/c-runtime-library/reference/difftime-difftime32-difftime64.md b/docs/c-runtime-library/reference/difftime-difftime32-difftime64.md index b5825758e2..b1512299fa 100644 --- a/docs/c-runtime-library/reference/difftime-difftime32-difftime64.md +++ b/docs/c-runtime-library/reference/difftime-difftime32-difftime64.md @@ -8,7 +8,6 @@ api_type: ["DLLExport"] topic_type: ["apiref"] f1_keywords: ["_difftime64", "difftime", "difftime64", "_difftime32", "difftime32"] helpviewer_keywords: ["_difftime32 function", "difftime function", "time, finding the difference", "difftime64 function", "_difftime64 function", "difftime32 function"] -ms.assetid: 4cc0ac2b-fc7b-42c0-8283-8c9d10c566d0 --- # `difftime`, `_difftime32`, `_difftime64` @@ -17,7 +16,7 @@ Finds the difference between two times. ## Syntax ```C -double difftime( time_t timeEnd, time_t timeStart ); +double difftime( time_t timeEnd, time_t timeStart ); // See note in remarks section about linkage double _difftime32( __time32_t timeEnd, __time32_t timeStart ); double _difftime64( __time64_t timeEnd, __time64_t timeStart ); ``` @@ -46,13 +45,18 @@ These functions validate their parameters. If either of the parameters is zero o By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md). +> [!Note] +> If you use Windows SDK version 10.0.26100.6901 and Visual Studio 2026 or later together, `difftime` is no longer `static inline` (internal linkage). Instead, it's `inline` (external linkage).\ +> To return to the previous behavior, `#define _STATIC_INLINE_UCRT_FUNCTIONS=1` before including any CRT headers. By default, `_STATIC_INLINE_UCRT_FUNCTIONS` is set to 0.\ +> This change increases UCRT conformance with the C++ standard and improves compatibility with C++ modules. + ## Requirements | Routine | Required header | |---|---| -| **`difftime`** | \ | -| **`_difftime32`** | \ | -| **`_difftime64`** | \ | +| **`difftime`** | `` | +| **`_difftime32`** | `` | +| **`_difftime64`** | `` | For more compatibility information, see [Compatibility](../compatibility.md). diff --git a/docs/c-runtime-library/reference/futime-futime32-futime64.md b/docs/c-runtime-library/reference/futime-futime32-futime64.md index a8b3805809..43712b0494 100644 --- a/docs/c-runtime-library/reference/futime-futime32-futime64.md +++ b/docs/c-runtime-library/reference/futime-futime32-futime64.md @@ -17,7 +17,7 @@ Sets the modification time on an open file. ## Syntax ```C -int _futime( +int _futime( // See note in remarks section about linkage int fd, struct _utimbuf *filetime ); @@ -51,13 +51,18 @@ The **`_futime`** routine sets the modification date and the access time on the By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md). +> [!Note] +> If you use Windows SDK version 10.0.26100.6901 and Visual Studio 2026 or later together, `_futime` is no longer `static inline` (internal linkage). Instead, it's `inline` (external linkage).\ +> To return to the previous behavior, `#define _STATIC_INLINE_UCRT_FUNCTIONS=1` before including any CRT headers. By default, `_STATIC_INLINE_UCRT_FUNCTIONS` is set to 0.\ +> This change increases UCRT conformance with the C++ standard and improves compatibility with C++ modules. + ## Requirements | Function | Required header | Optional header | |---|---|---| -| **`_futime`** | \ | \ | -| **`_futime32`** | \ | \ | -| **`_futime64`** | \ | \ | +| **`_futime`** | `` | `` | +| **`_futime32`** | `` | `` | +| **`_futime64`** | `` | `` | For more compatibility information, see [Compatibility](../compatibility.md). diff --git a/docs/c-runtime-library/reference/gmtime-gmtime32-gmtime64.md b/docs/c-runtime-library/reference/gmtime-gmtime32-gmtime64.md index 1d0656b3f7..82ac3231da 100644 --- a/docs/c-runtime-library/reference/gmtime-gmtime32-gmtime64.md +++ b/docs/c-runtime-library/reference/gmtime-gmtime32-gmtime64.md @@ -16,7 +16,7 @@ Converts a `time_t` time value to a `tm` structure. More secure versions of thes ## Syntax ```C -struct tm *gmtime( const time_t *sourceTime ); +struct tm *gmtime( const time_t *sourceTime ); // See note in remarks section about linkage struct tm *_gmtime32( const __time32_t *sourceTime ); struct tm *_gmtime64( const __time64_t *sourceTime ); ``` @@ -56,6 +56,11 @@ The **`_gmtime32`** function breaks down the *`sourceTime`* value and stores it By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md). +> [!Note] +> When you use Windows SDK version 10.0.26100.6901 and Visual Studio 2026 or later together, `gmtime` is no longer `static inline` (internal linkage). Instead, it's `inline` (external linkage).\ +> To return to the previous behavior, `#define _STATIC_INLINE_UCRT_FUNCTIONS=1` before including any CRT headers. By default, `_STATIC_INLINE_UCRT_FUNCTIONS` is set to 0.\ +> This change increases UCRT conformance with the C++ standard and improves compatibility with C++ modules. + ## Requirements | Routine | Required C header | Required C++ header | diff --git a/docs/c-runtime-library/reference/gmtime-s-gmtime32-s-gmtime64-s.md b/docs/c-runtime-library/reference/gmtime-s-gmtime32-s-gmtime64-s.md index 9151701714..36f21d43df 100644 --- a/docs/c-runtime-library/reference/gmtime-s-gmtime32-s-gmtime64-s.md +++ b/docs/c-runtime-library/reference/gmtime-s-gmtime32-s-gmtime64-s.md @@ -16,7 +16,7 @@ Converts a time value to a `tm` structure. These functions are versions of [`_gm ## Syntax ```C -errno_t gmtime_s( +errno_t gmtime_s( // See note in remarks section about linkage struct tm* tmDest, const __time_t* sourceTime ); @@ -76,6 +76,11 @@ Each of the structure fields is of type **`int`**, as shown in the following tab By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md). +> [!Note] +> When you use Windows SDK version 10.0.26100.6901 and Visual Studio 2026 or later together, `gmtime_s` is no longer `static inline` (internal linkage). Instead, it's `inline` (external linkage).\ +> To return to the previous behavior, `#define _STATIC_INLINE_UCRT_FUNCTIONS=1` before including any CRT headers. By default, `_STATIC_INLINE_UCRT_FUNCTIONS` is set to 0.\ +> This change increases UCRT conformance with the C++ standard and improves compatibility with C++ modules. + ## Requirements | Routine | Required C header | Required C++ header | diff --git a/docs/c-runtime-library/reference/localtime-localtime32-localtime64.md b/docs/c-runtime-library/reference/localtime-localtime32-localtime64.md index 746082c2ad..b5f537a55a 100644 --- a/docs/c-runtime-library/reference/localtime-localtime32-localtime64.md +++ b/docs/c-runtime-library/reference/localtime-localtime32-localtime64.md @@ -17,7 +17,7 @@ Converts a time value and corrects for the local time zone. More secure versions ## Syntax ```C -struct tm *localtime( const time_t *sourceTime ); +struct tm *localtime( const time_t *sourceTime ); // See note in remarks section about linkage struct tm *_localtime32( const __time32_t *sourceTime ); struct tm *_localtime64( const __time64_t *sourceTime ); ``` @@ -72,6 +72,11 @@ These functions validate their parameters. If *`sourceTime`* is a null pointer, By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md). +> [!Note] +> When you use Windows SDK version 10.0.26100.6901 and Visual Studio 2026 or later together, `localtime` is no longer `static inline` (internal linkage). Instead, it's `inline` (external linkage).\ +> To return to the previous behavior, `#define _STATIC_INLINE_UCRT_FUNCTIONS=1` before including any CRT headers. By default, `_STATIC_INLINE_UCRT_FUNCTIONS` is set to 0.\ +> This change increases UCRT conformance with the C++ standard and improves compatibility with C++ modules. + ## Requirements | Routine | Required C header | Required C++ header | diff --git a/docs/c-runtime-library/reference/localtime-s-localtime32-s-localtime64-s.md b/docs/c-runtime-library/reference/localtime-s-localtime32-s-localtime64-s.md index 64aebc449d..430f90328b 100644 --- a/docs/c-runtime-library/reference/localtime-s-localtime32-s-localtime64-s.md +++ b/docs/c-runtime-library/reference/localtime-s-localtime32-s-localtime64-s.md @@ -17,7 +17,7 @@ Converts a **`time_t`** time value to a **`tm`** structure, and corrects for the ## Syntax ```C -errno_t localtime_s( +errno_t localtime_s( // See note in remarks section about linkage struct tm* const tmDest, time_t const* const sourceTime ); @@ -84,6 +84,11 @@ If the **`TZ`** environment variable is set, the C run-time library assumes rule By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md). +> [!Note] +> When you use Windows SDK version 10.0.26100.6901 and Visual Studio 2026 or later together, `localtime_s` is no longer `static inline` (internal linkage). Instead, it's `inline` (external linkage).\ +> To return to the previous behavior, `#define _STATIC_INLINE_UCRT_FUNCTIONS=1` before including any CRT headers. By default, `_STATIC_INLINE_UCRT_FUNCTIONS` is set to 0.\ +> This change increases UCRT conformance with the C++ standard and improves compatibility with C++ modules. + ## Requirements | Routine | Required C header | Required C++ header | diff --git a/docs/c-runtime-library/reference/mkgmtime-mkgmtime32-mkgmtime64.md b/docs/c-runtime-library/reference/mkgmtime-mkgmtime32-mkgmtime64.md index c692db9900..037c907886 100644 --- a/docs/c-runtime-library/reference/mkgmtime-mkgmtime32-mkgmtime64.md +++ b/docs/c-runtime-library/reference/mkgmtime-mkgmtime32-mkgmtime64.md @@ -16,7 +16,7 @@ Converts a UTC time represented by a **`struct tm`** to a UTC time represented b ## Syntax ```C -time_t _mkgmtime( +time_t _mkgmtime( // See note in remarks section about linkage struct tm* timeptr ); __time32_t _mkgmtime32( @@ -48,6 +48,11 @@ The range of the **`_mkgmtime32`** function is from midnight, January 1, 1970, U Both **`gmtime`** and **`localtime`** use a common static buffer for the conversion. If you supply this buffer to **`_mkgmtime`**, the previous contents are destroyed. +> [!Note] +> When you use Windows SDK version 10.0.26100.6901 and Visual Studio 2026 or later together, `_mkgmtime` is no longer `static inline` (internal linkage). Instead, it's `inline` (external linkage).\ +> To return to the previous behavior, `#define _STATIC_INLINE_UCRT_FUNCTIONS=1` before including any CRT headers. By default, `_STATIC_INLINE_UCRT_FUNCTIONS` is set to 0.\ +> This change increases UCRT conformance with the C++ standard and improves compatibility with C++ modules. + ## Examples ```C diff --git a/docs/c-runtime-library/reference/mktime-mktime32-mktime64.md b/docs/c-runtime-library/reference/mktime-mktime32-mktime64.md index 51d9a4265a..7f7bb31a6c 100644 --- a/docs/c-runtime-library/reference/mktime-mktime32-mktime64.md +++ b/docs/c-runtime-library/reference/mktime-mktime32-mktime64.md @@ -16,7 +16,7 @@ Convert the local time to a calendar value. ## Syntax ```C -time_t mktime( +time_t mktime( // See note in remarks section about linkage struct tm *timeptr ); __time32_t _mktime32( @@ -62,6 +62,11 @@ These functions validate their parameter. If *`timeptr`* is a null pointer, the By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md). +> [!Note] +> When you use Windows SDK version 10.0.26100.6901 and Visual Studio 2026 or later together, `mktime` is no longer `static inline` (internal linkage). Instead, it's `inline` (external linkage).\ +> To return to the previous behavior, `#define _STATIC_INLINE_UCRT_FUNCTIONS=1` before including any CRT headers. By default, `_STATIC_INLINE_UCRT_FUNCTIONS` is set to 0.\ +> This change increases UCRT conformance with the C++ standard and improves compatibility with C++ modules. + ## Requirements | Routine | Required header | diff --git a/docs/c-runtime-library/reference/strnlen-strnlen-s.md b/docs/c-runtime-library/reference/strnlen-strnlen-s.md index d74f2d71dc..ba5972caae 100644 --- a/docs/c-runtime-library/reference/strnlen-strnlen-s.md +++ b/docs/c-runtime-library/reference/strnlen-strnlen-s.md @@ -24,7 +24,7 @@ size_t strnlen( const char *str, size_t numberOfElements ); -size_t strnlen_s( +size_t strnlen_s( // See note in remarks section about linkage const char *str, size_t numberOfElements ); @@ -32,7 +32,7 @@ size_t wcsnlen( const wchar_t *str, size_t numberOfElements ); -size_t wcsnlen_s( +size_t wcsnlen_s( // See note in remarks section about linkage const wchar_t *str, size_t numberOfElements ); @@ -88,6 +88,11 @@ Each of these functions returns the number of characters in *`str`*, not includi By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md). +> [!Note] +> When you use Windows SDK version 10.0.26100.6901 and Visual Studio 2026 or later together, `strnlen_s` and `wcsnlen_s` are no longer `static inline` (internal linkage). Instead, they are `inline` (external linkage).\ +> To return to the previous behavior, `#define _STATIC_INLINE_UCRT_FUNCTIONS=1` before including any CRT headers. By default, `_STATIC_INLINE_UCRT_FUNCTIONS` is set to 0.\ +> This change increases UCRT conformance with the C++ standard and improves compatibility with C++ modules. + ### Generic-text routine mappings | `TCHAR.H` routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined | diff --git a/docs/c-runtime-library/reference/time-time32-time64.md b/docs/c-runtime-library/reference/time-time32-time64.md index 782e7aa835..1087f1997a 100644 --- a/docs/c-runtime-library/reference/time-time32-time64.md +++ b/docs/c-runtime-library/reference/time-time32-time64.md @@ -8,7 +8,6 @@ api_type: ["DLLExport"] topic_type: ["apiref"] f1_keywords: ["TIME/time", "TIME/_time32", "TIME/_time64", "time", "_time32", "_time64"] helpviewer_keywords: ["time32 function", "_time32 function", "_time64 function", "time functions", "system time", "time64 function"] -ms.assetid: 280e00f2-2b93-4ece-94cd-e048484c6cc7 --- # `time`, `_time32`, `_time64` @@ -17,7 +16,7 @@ Gets the system time. ## Syntax ```C -time_t time( time_t *destTime ); +time_t time( time_t *destTime ); // See note in remarks section about linkage __time32_t _time32( __time32_t *destTime ); __time64_t _time64( __time64_t *destTime ); ``` @@ -37,6 +36,11 @@ The **`time`** function returns the number of seconds elapsed since midnight (00 **`time`** is a wrapper for **`_time64`** and **`time_t`** is, by default, equivalent to **`__time64_t`**. If you need to force the compiler to interpret **`time_t`** as the old 32-bit **`time_t`**, you can define `_USE_32BIT_TIME_T`. We don't recommend `_USE_32BIT_TIME_T`, because your application may fail after January 18, 2038; the use of this macro isn't allowed on 64-bit platforms. +> [!Note] +> When you use Windows SDK version 10.0.26100.6901 and Visual Studio 2026 or later together, `time` is no longer `static inline` (internal linkage). Instead, it's `inline` (external linkage).\ +> To return to the previous behavior, `#define _STATIC_INLINE_UCRT_FUNCTIONS=1` before including any CRT headers. By default, `_STATIC_INLINE_UCRT_FUNCTIONS` is set to 0.\ +> This change increases UCRT conformance with the C++ standard and improves compatibility with C++ modules. + ## Requirements | Routine | Required C header | Required C++ header | diff --git a/docs/c-runtime-library/reference/timespec-get-timespec32-get-timespec64-get1.md b/docs/c-runtime-library/reference/timespec-get-timespec32-get-timespec64-get1.md index e14e404ae6..fea1cd33a5 100644 --- a/docs/c-runtime-library/reference/timespec-get-timespec32-get-timespec64-get1.md +++ b/docs/c-runtime-library/reference/timespec-get-timespec32-get-timespec64-get1.md @@ -17,7 +17,7 @@ Sets the interval pointed to by the first argument to the current calendar time, ## Syntax ```C -int timespec_get( +int timespec_get( // See note in remarks section about linkage struct timespec* const time_spec, int const base ); @@ -55,6 +55,11 @@ These functions support only `TIME_UTC` as the *`base`* value. `TIME_UTC` sets t By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md). +> [!Note] +> When you use Windows SDK version 10.0.26100.6901 and Visual Studio 2026 or later together, `timespec_get` is no longer `static inline` (internal linkage). Instead, it's `inline` (external linkage).\ +> To return to the previous behavior, `#define _STATIC_INLINE_UCRT_FUNCTIONS=1` before including any CRT headers. By default, `_STATIC_INLINE_UCRT_FUNCTIONS` is set to 0.\ +> This change increases UCRT conformance with the C++ standard and improves compatibility with C++ modules. + ## Requirements | Routine | Required header | diff --git a/docs/c-runtime-library/reference/utime-utime32-utime64-wutime-wutime32-wutime64.md b/docs/c-runtime-library/reference/utime-utime32-utime64-wutime-wutime32-wutime64.md index d5a82ee0b6..84b91e8d2e 100644 --- a/docs/c-runtime-library/reference/utime-utime32-utime64-wutime-wutime32-wutime64.md +++ b/docs/c-runtime-library/reference/utime-utime32-utime64-wutime-wutime32-wutime64.md @@ -8,7 +8,6 @@ api_type: ["DLLExport"] topic_type: ["apiref"] f1_keywords: ["UTIME/_utime", "UTIME/_utime32", "UTIME/_utime64", "UTIME/_wutime", "UTIME/_wutime32", "UTIME/_wutime64", "TCHAR/_tutime", "TCHAR/_tutime32", "TCHAR/_tutime64", "_utime", "_utime32", "_utime64", "_wutime", "_wutime32", "_wutime64", "_tutime", "_tutime32", "_tutime64"] helpviewer_keywords: ["tutime function", "utime32 function", "utime64 function", "_utime function", "_tutime32 function", "time [C++], file modification", "wutime function", "_wutime function", "_wutime32 function", "_tutime64 function", "_tutime function", "files [C++], modification time", "_wutime64 function", "_utime32 function", "utime function", "_utime64 function", "wutime64 function", "wutime32 function", "tutime64 function", "tutime32 function"] -ms.assetid: 8d482d40-19b9-4591-bfee-5d7f601d1a9e --- # `_utime`, `_utime32`, `_utime64`, `_wutime`, `_wutime32`, `_wutime64` @@ -17,7 +16,7 @@ Set the file modification time. ## Syntax ```C -int _utime( +int _utime( // See note in remarks section about linkage const char *filename, struct _utimbuf *times ); @@ -29,7 +28,7 @@ int _utime64( const char *filename, struct __utimbuf64 *times ); -int _wutime( +int _wutime( // See note in remarks section about linkage const wchar_t *filename, struct _utimbuf *times ); @@ -85,6 +84,11 @@ Specific versions of the `_utimbuf` structure (`__utimbuf32` and `__utimbuf64`) By default, this function's global state is scoped to the application. To change this behavior, see [Global state in the CRT](../global-state.md). +> [!Note] +> When you use Windows SDK version 10.0.26100.6901 and Visual Studio 2026 or later together, `_utime` and `_wutime` are no longer `static inline` (internal linkage). Instead, they're `inline` (external linkage).\ +> To return to the previous behavior, `#define _STATIC_INLINE_UCRT_FUNCTIONS=1` before including any CRT headers. By default, `_STATIC_INLINE_UCRT_FUNCTIONS` is set to 0.\ +> This change increases UCRT conformance with the C++ standard and improves compatibility with C++ modules. + ### Generic-text routine mappings | TCHAR.H routine | `_UNICODE` and `_MBCS` not defined | `_MBCS` defined | `_UNICODE` defined | diff --git a/docs/get-started/toc.yml b/docs/get-started/toc.yml index 49961e1320..bc7a83fb97 100644 --- a/docs/get-started/toc.yml +++ b/docs/get-started/toc.yml @@ -6,6 +6,8 @@ items: href: ../build/vscpp-step-0-installation.md - name: Visual Studio guided tour href: /visualstudio/get-started/visual-studio-ide + - name: Use AI to create a C++ console application in Visual Studio + href: ../build/use-github-copilot-create-cpp-console-app.md - name: Create and edit a C++ console app project href: ../build/vscpp-step-1-create.md - name: Build and run a C++ console app project