C++ Builder

How To Use Variable Templates In Modern C++

The template is one of the great features of modern C++. They are a simple and very powerful statement in C++ that defines the operations of a class or function. The C++14 standard and above allows the creation of variables that are templated. In this article, we will explain variable templates in C++ with examples that can be used in a professional IDE and compiler that supports C++14, C++17, and over.  First of all, let’s remind ourselves what a C++ template is. What is a template in C++? A template is a very powerful statement in C++ that simply defines the operations of a class, a function, an alias, or a variable and lets the user apply the same template on different types in those template operations. Templates are like macros in C++, considered in compilation except compiler checks types used before the template is expanded in its terms. In the compilation mechanism of a template in C++, the source code contains only a template for a function or class, but when it is compiled, the same template can be used on multiple data types. Templates are powerful entities that can be parameterized by one or more parameters. These parameters can be type template parameters, non-type template parameters, and template template parameters (parameters which are themselves templates). What is a variable template in modern C++? A variable template is used to define a family of variables or static data members. If a static data member is instantiated from a static data member template, it is called an instantiated static data member. A variable template can be introduced by a template declaration at namespace scope, where a variable declaration declares a variable. The C++14  standard and above allows the creation of variables that are templated. In C++11, only functions, classes, or type aliases could be templated.  Syntax of a variable template;   template variable_declaration   The usual rules of templates apply to such declarations and definitions, including specialization. Where is a simple variable template example in modern C++? Variable templates are used to instantiate the variables separately for the type. For example, we can assign 9.80665 to the g variable in T form ( i.e. T(9.80665) ) as a float or double or long double type and that would be g or g or g or g in template usage. Here is a simple variable template example that is used to define standard gravity value.   template constexpr T gravity = T(9.80665);   Is there a variable template instantiation example in modern C++? Now, let’s use this in a template. We can define a force template (force = mass x gravity) as shown below:   template T force(T mass) // function template { return mass*gravity; // gravity is a variable template instantiation }   here gravity is a variable template instantiation. Is there a full example of variable templates in modern C++? Here is an example variable template instantiation to different types. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29   #include   template T gravity = T(9.80665);   // template constexpr T gravity = T(9.80665);   template T force(T mass) // function template { return mass*gravity; // gravity is a variable template instantiation } int main() { auto g1 = gravity; […]

Read More

C11 Threads in Visual Studio 2022 version 17.8 Preview 2

C11 Threads in Visual Studio 2022 version 17.8 Preview 2 Charlie Barto September 26th, 20232 3 Back in Visual Studio 2022 version 17.5 Microsoft Visual C gained preliminary support for C11 atomics. We are happy to announce that support for the other major concurrency feature of C11, threads, is available in Visual Studio version 17.8 Preview 2. This should make it easier to port cross-platform C applications to Windows, without having to drag along a threading compatibility layer. Unlike C11 atomics, C11 threads do not share an ABI with C++’s facilities, but C++ programs can include the C11 threads header and call the functions just like any C program. Both are implemented in terms of the primitives provided by Windows, so their usage can be mixed in the same program and on the same thread. The implementations are distinct, however, for example you can’t use the C11 mutexes with C++ condition variables. C11 contains support for threads and a variety of related concurrency primitives including mutexes, condition variables, and thread specific storage. All of these are implemented in Visual Studio version 17.8 Preview 2. Threads Threads are created with thrd_create, to which you pass a pointer to the desired entry point and a user data pointer (which may be null), along with a pointer to a thrd_t structure to fill in. Once you have a thrd_t created with thrd_create you can call functions to compare it to another thrd_t, join it, or detach it. Functions are also provided to sleep or yield the current thread. int thread_entry(void* data) { return 0; } int main(void) { thrd_t thread; int result = thrd_create(&thread, thread_entry, NULL); if(result != thrd_success) { // handle error } result = thrd_join(thread, NULL); if(result != thrd_success) { // handle error } return 0; }   A key difference between our implementation and C11 threads implementations based on pthreads is that threads can not detach themselves using thrd_current() and thrd_detach(). This is because of a fundamental difference in how threads work on Windows vs Unix descendants and we would require a shared datastructure that tracks thread handles to implement the typical behavior. On Unix derivatives the integer thread ID is the handle to the thread and detaching just sets a flag causing the thread to be cleaned up immediately when it finishes. This makes detached threads somewhat dangerous to use on Unix derivatives, since after a detached thread exits any other references to that thread ID will be dangling and could later refer to a different thread altogether. On Windows the handle to a thread is a win32 HANDLE and is reference counted. The thread is cleaned up when the last handle is closed. There is no way to close all handles to a thread except by keeping track of them and closing each one. We could implement the Unix/pthreads behavior by keeping a shared mapping of thread-id to handle, populated by thrd_create. If you need this functionality then you can implement something like this yourself, but we don’t provide it by default because it would incur a cost even if it’s not used. Better workarounds may also be available, such as passing a pointer to the thrd_t populated by thrd_create via the user data pointer to the created thread. Mutexes Mutexes are provided through the mtx_t structure and […]

Read More

Clang v15 compiler support coming to C++Builder 12

For C++ developers who want to take advantage of new ISO C++ language features in Clang v15 along with the power and productivity of RAD development using C++Builder, stay tuned to the Embarcadero blogs and C++Builder product website for news about the next release of C++Builder. Note: “This blog post is based on a pre-release version of the RAD Studio software and it has been written with specific permission by Embarcadero. No feature is committed until the product GA release.” David Millington, Embarcadero Product Manager, on August 31, 2023 presented a webinar titled “Behind the Build: RAD Studio and C++Builder 12.0” that previewed the upcoming Clang compiler upgrade and integration of Whole Tomato’s Visual Assist into the IDE.  You can watch the replay of the webinar at https://www.youtube.com/watch?v=B0Be_NFmEEE The next release of C++Builder with Clang v15 support will include the following toolchain enhancements: Clang: based on Clang 15, named ‘bcc64x’ C runtime: uses the Universal C Runtime (UCRT) C++ runtime: a new RTL, based on several open source areas STL: libc++ Linker: LLVM lld Debug format: PDB (with IDE support) The toolchain emits COFF object files and uses the Itanium ABI and mangling The default language standard is C++17 and C99 Here are two screen grabs from the August 31, 2023 David Millington webinar: Embarcadero Special Offer: Buy RAD 11.3 today and Apply to join the RAD 12 beta The promotional offer is ending soon (4 days left as of this blog post). Find out additional information at https://www.embarcadero.com/radoffer Keep Up To Date on C++Builder and ISO C++ To keep up to date on using C++Builder and the ISO C++ language you should absolutely bookmark and read everything that Yılmaz Yörü posts on his Embarcadero blog at https://blogs.embarcadero.com/author/yilmazyoru/ Yilmaz also has a great site for learning C++ at https://learncplusplus.org/ Stay tuned to the Embarcadero C++Builder product page for additional information and news.   Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder. Design. Code. Compile. Deploy. Start Free Trial   Upgrade Today    Free Delphi Community Edition   Free C++Builder Community Edition

Read More

MSVC Machine-Independent Optimizations in Visual Studio 2022 17.7

MSVC Machine-Independent Optimizations in Visual Studio 2022 17.7 Troy Johnson September 25th, 20232 3 This blog post presents a selection of machine-independent optimizations that were added between Visual Studio versions 17.4 (released November 8, 2022) and 17.7 P3 (released July 11, 2023). Each optimization below shows assembly code for both X64 and ARM64 to show the machine-independent nature of the optimization. Optimizing Memory Across Block Boundaries When a small struct is loaded into a register, we can optimize field accesses to extract the correct bits from the register instead of accessing it through memory. Historically in MSVC, this optimization has been limited to memory accesses within the same basic block. We are now able to perform this same optimization across block boundaries in many cases. In the example ASM listings below, a load to the stack and a store from the stack are eliminated, resulting in less memory traffic as well as lower stack memory usage. Example C++ Source Code: #include bool compare(const std::string_view& l, const std::string_view& r) {    return l == r; } Required Compiler Flags: /O2 X64 ASM: 17.4 17.7 sub        rsp, 56 movups  xmm0, XMMWORD PTR [rcx] mov        r8, QWORD PTR [rcx+8] movaps  XMMWORD PTR $T1[rsp], xmm0 cmp        r8, QWORD PTR [rdx+8] jne        SHORT $LN9@compare mov        rdx, QWORD PTR [rdx] mov        rcx, QWORD PTR $T1[rsp] call       memcmp test       eax, eax jne        SHORT $LN9@compare mov        al, 1 add        rsp, 56 ret        0 $LN9@compare: xor        al, al add        rsp, 56 ret        0 sub         rsp, 40 mov        r8, QWORD PTR [rcx+8] movups  xmm1, XMMWORD PTR [rcx] cmp        r8, QWORD PTR [rdx+8] jne         SHORT $LN9@compare mov        rdx, QWORD PTR [rdx] movq      rcx, xmm1 call        memcmp test        eax, eax jne         SHORT $LN9@compare mov        al, 1 add         rsp, 40 ret         0 $LN9@compare: xor         al, al add         rsp, 40 ret         0   ARM64 ASM: 17.4 17.7 str         lr,[sp,#-0x10]! sub         sp,sp,#0x20 ldr         q17,[x1] ldr         q16,[x0] umov        x8,v17.d[1] umov        x2,v16.d[1] stp         q17,q16,[sp] cmp         x2,x8 bne         |$LN9@compare| ldr         x1,[sp] ldr         x0,[sp,#0x10] bl          memcmp cbnz        w0,|$LN9@compare| mov         w0,#1 add         sp,sp,#0x20 ldr         lr,[sp],#0x10 ret |$LN9@compare| mov         w0,#0 add         sp,sp,#0x20 ldr         lr,[sp],#0x10 ret str         lr,[sp,#-0x10]! ldr         q17,[x1] ldr         q16,[x0] umov        x8,v17.d[1] umov        x2,v16.d[1] cmp         x2,x8 bne         |$LN9@compare| fmov        x1,d17 fmov        x0,d16 bl          memcmp cbnz        w0,|$LN9@compare| mov         w0,#1 ldr         lr,[sp],#0x10 ret |$LN9@compare| mov         w0,#0 ldr         lr,[sp],#0x10 ret   Vector Logical and Arithmetic Optimizations We continue to add patterns for recognizing vector operations that are equivalent to intrinsics or short sequences of intrinsics. An example is recognizing common forms of vector absolute difference calculations. A long series of bitwise instructions can be replaced with specialized absolute value instructions, such as vpabsd on X64 and sabd on ARM64. Example C++ Source Code: #include void s32_1(int * __restrict a, int * __restrict b, int * __restrict c, int n) { for (int i = 0; i < n; i++) { a[i] = (b[i] - c[i]) > 0 ? (b[i] – c[i]) : (c[i] – b[i]); } } Required Flags: /O2 /arch:AVX for X64, /O2 for ARM64 X64 ASM: 17.4 17.7 $LL4@s32_1: movdqu  xmm0, XMMWORD PTR [r11+rax] add     ecx, 4 movdqu  xmm1, XMMWORD PTR [rax] lea     rax, QWORD PTR [rax+16] movdqa  xmm3, xmm0 psubd   xmm3, xmm1 psubd   xmm1, xmm0 movdqa  xmm2, xmm3 pcmpgtd xmm2, xmm4 movdqa  xmm0, xmm2 andps   xmm2, xmm3 andnps  xmm0, xmm1 orps    xmm0, xmm2 movdqu  XMMWORD PTR [r10+rax-16], xmm0 cmp     ecx, edx jl      SHORT $LL4@s32_1 $LL4@s32_1: vmovdqu xmm1, XMMWORD PTR [r10+rax] vpsubd     xmm1, xmm1, XMMWORD PTR [rax] vpabsd     xmm2, […]

Read More

What Is Aggregate Member Initialization In C++?

The Aggregate Member Initialization is one of the features of C++. This feature is improved and modernized with C++11, C++14 and C++20. With this feature, objects can initialize an aggregate member from braced-init-list. In this post, we explain what the aggregate member initialization is and what were the changes to it in modern C++ standards. What is aggregate member initialization in modern C++? Aggregate initialization initializes aggregates. Since C++11, aggregates are a form of listed initializations. Since C++20 they are direct initializations. An aggregate could be an array or class type (a class, a struct, or a union).  Here is the general syntax,   T object = {arg1, arg2, …};   In C++11 and above, we use without = as below,   T object {arg1, arg2, …};   In C++20, there are 3 new options that we can use,   T object (arg1, arg2, …); T object = { .designator = arg1 , .designator { arg2 } … }; T object { .designator = arg1 , .designator { arg2 } … };   How to use aggregate member initialization in modern C++? C++14 provides a solution to problems in C++11 and above, for example in C++14, consider we have x, y coordinates in a struct, we can initialize them as below in a new xy object,   struct st_xy { float x, y; };   struct st_xy xy{ 3.2f, 5.1f };   In modern C++, consider that we have a struct that has a, b, c members. We initialize first two members as below,   struct st_x { short int a, b, c; };   struct st_x x{ .a = 10, .b = 20}; // x.c will be 0   We can directly initialize as below too,   struct st_y { int a = 100, b = 200, c, d; } y;   In C++17 and above, we can use this st_y as a base and we can add a new member to a new struct, then we can initialize as below,   struct st_z : st_y { int e; };   struct st_z z{ 1, 2, 3, 4, 5};   What restrictions are there for the aggregate member initialization in C++? If we consider the C++17 standard, an aggregate initialization can NOT be applied to a class type if it has one of the below, private or protected non-static data members, a constructor that is user-provided, inherited, or explicit constructors (explicitly defaulted or deleted constructors are allowed), base class or classes (virtual, private, protected), virtual member functions If we consider the C++20 standard, an aggregate initialization can NOT be applied to a class type if it has one of the below, private or protected non-static data members, user-declared or inherited constructors, base class or classes (virtual, private, protected), virtual member functions Is there a full example of aggregate member initialization in C++? Here is a full example that explains simply most used features of aggregate member initialization, 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42   #include   // Aggregate in C++14 struct st_xy { float a, b; };   struct st_xy xy{ 3.2f, 5.1f };   struct st_x { […]

Read More

Learn To Use Generalized Lambda Captures In C++

Impact-Site-Verification: 9054929b-bb39-4974-9313-38176602ccee The Lambda Expression construct is introduced in C++ 11 and further developed in the C++14, C++17, and C++20 standards. C++14 standard introduced the generalized lambda capture (init capture) that allows you to specify generalized captures, it allows to use move capture in lambdas. In C++14, lambda expressions are improved by the generalized lambda (generic lambda) and by this generalized lambda captures. In this post, we explain how to use generalized lambda captures in modern C++ What is a lambda in C++? A Lambda Expression defines an anonymous function or a closure at the point where it is used. You can think of a lambda expression as an unnamed function (that’s why it’s called “anonymous”). Lambda expressions help make code cleaner, and more concise and allow you to see behavior inline where it’s defined instead of referring to an external method, like a function. Lambda Expressions are an expression that returns a function object, and they are assignable to a variable whose data type is usually auto and defines a function object. The syntax for a lambda expression consists of specific punctuation with = [ ] ( ) { … } series. If you are new to lambdas or want to know more about them, please check these two posts that we released before. How to use a generalized lambda function in C++ Before C++14, lambda function parameters need to be declared with concrete types, as in the given example above. C++14 has a new generic lambda feature that allows lambda function parameters to be declared with the auto-type specifier. The basic syntax of a Lambda Expression in C++ is; Datatype Lambda Expression = [Capture Clause] (Parameter List) -> Return Type { Body } Generalized lambdas can be defined with the auto keyword that comes with C++11. We can define a generic lambda with the auto keyword as below. auto add_things = []( auto a, auto b ) {    return a + b; }; We can use this lambda with an int type, int x = add_things( 10, 20 ); or we can use it with a float type, float f = add_things( 10.f, 20.f ); or we can use it with bool, char, double, long long double,… etc types. This is why it is called as ‘generalized‘, it is a general form that we can use with any types. Very useful and powerful. What are generalized lambda captures in C++? The Lambda Expression construct is introduced in C++ 11 and further developed in the C++14, C++17, and C++20 standards. C++14 standard introduced the generalized lambda capture (also known as init capture) that allows you to specify generalized captures. In C++14, lambda expressions are improved by the generalized lambda (generic lambda) and by this generalized lambda captures, it allows to use move capture in lambdas. A generalized capture is a new and more general capture mechanism, it allows us to specify the name of a data member in the closure class generated from the lambda, and an expression initializing that data member. Lambdas can capture expressions, rather than just variables as in functions, and this feature allows lambdas to store move-only types. How to use generalized lambda captures in C++ Let’s see how we can use generalized lambda captures in modern C++, std::move can be used to move objects in lambda captures as below, struct […]

Read More

What Is Auto Return Type Deduction In C++?

C++11 allowed lambda functions to deduce the return type based on the type of the expression given to the return statement. The C++14 standard provides return type deduction in all functions, templates, and lambdas. C++14 allows return type deduction for functions that are not of the form return expressions. In this post, we explain the auto keyword, what is an auto type deduction, and how we can use it in functions, templates, and lambdas. Here are some very simple examples. What is the auto keyword in C++? The auto keyword arrives with the new features of the C++11 standard and above. It can be used as a placeholder type specifier (an auto-typed variable), or it can be used in a function declaration, or a structured binding declaration. The auto keyword can be used with other new CLANG standards like C++14, C++17, etc. Here is a simple example of how to use auto-typed variables in C++.   unsigned long int L;   auto a = L; // a is automatically unsigned long int   The auto keyword was being used as an automatic data specifier (storage class specifier) until C++11. This feature was removed by the C++11 standard. What is auto return type deduction in C++? In object oriented programming, type inference or deduction means the automatic detection of the data type of an expression and its conversion to a new type in a programming language and auto return type deduction may deduce return. type (i.e. float parameters to int return values). By the C++14 standard, we can use auto return type deduction in functions, templates, in lambdas. Now let’s see some simple examples that show how we can use them. If you want to use return type deduction in functions, templates, and lambdas, it must be declared with auto as the return type, but without the trailing return type specifier in C++11. The auto return type deduction feature can be used with parameter types in functions. Here is a simple example,   auto sq(int r)   // auto return type deduction in function { return r*r; }   The auto return type deduction feature can be used on modified parameters. Here is a simple example.   auto inc(int r)  // auto return type deduction in function { return ++r; }   The auto return type deduction feature can be used with references in functions.   auto& zero(int& r) // auto return type deduction in function { r = 0; return r; }   The auto return type deduction can be used with templates. Here is an example:   template auto template_sq(T t) // auto return type deduction in template { return (int)(t*t); // deduce to int }   The auto keyword is very useful in lambda declarations and it has an auto return type deduction feature too. See a simple lambda example below.   auto lambda_sq = [](int r)  // auto return type deduction in lambda { return r*r; };   Note that one of the important differences between lambdas and normal functions is that normal functions can refer to themselves by name but lambdas cannot. Is there a full example of auto return type deduction in C++? Here is a full example about auto return type deduction in functions, a template and a lambda. 1 2 3 4 5 6 7 8 9 10 11 […]

Read More

Enhancing the CMake Targets View in Visual Studio

Enhancing the CMake Targets View in Visual Studio Sinem Akinci September 20th, 20231 2 The CMake Targets View in Visual Studio is a view that allows you to visualize your CMake project structure by the CMake targets and build specified target libraries and executables. To make this view more usable, we have implemented a few new improvements to make it easier than ever to navigate your CMake targets. This includes improved navigation to the CMake Targets View, a new, more simplified CMake Targets View, and the ability to exclude specified CMake items from the Targets View. Additionally, we have future planned work in the near-term to allow users to customize this view to their desired configuration. Download the latest preview version of Visual Studio to try out the new updates for the CMake Targets View. Get to your CMake Targets View Quicker Than Ever Customers have reported that it can be cumbersome to switch between CMake Targets View and the Solution Explorer. To address this, we have implemented new entry points to open the CMake Targets View much more quickly. Switch to your CMake Targets View from Solution Explorer Now, you can right-click anywhere in your Solution Explorer and simply navigate to the CMake Targets View from the context menu. Open the CMake Targets View from the ‘View’ Dropdown Menu You can also access the CMake Targets View globally at any point in your CMake projects by selecting from the View dropdown. Simplify your Source Navigation The CMake Targets View has been further simplified so that users don’t have to click through folders without buildable executables to get to their desired target.   Define Items to Exclude from View You can now define in your VSWorkspaceSettings.json items to exclude from the CMake Targets View using the new CMakeTargetsViewExcludedItems field. The CMakeTargetsViewExcludedItems field is an array of strings. The field supports the following syntax and identifiers: Supported “identifiers”: CMakeProject, CMakeTarget, CMakeReference, CMakeFolder, CMakeFile. Syntax for the CMakeTargetsViewExcludedItems is the following: : This will specify any identifier with the specified name. For example, CMakeTarget:app. Any CMake targets with the name “app” anywhere in the CMake Targets View will be excluded. Additionally, if you want to specify specific items to be excluded, you can use a – to chain declarations together::-:… For example, CMakeProject:thirdPartyDependency-CMakeTarget:irrelevantThirdParty. Example usage in a VSWorkspaceSettings.json: {   “CMakeTargetsViewExcludedItems”: [     “CMakeTarget:-CMakeFile:*”, “CMakeTarget-*-CMakeFile:*”, “CMakeTarget:-*-*-CMakeFile:*” } What’s Coming Next? We are continuing to develop the CMake Targets View to allow for further customization of this view based on customer feedback. Stay tuned for the latest updates as these ship in the future! We are planning to give users the ability to filter their CMake Targets view by type of target, project, etc. Users will be able to dynamically pin and unpin their most used targets to the top of the CMake Targets View. We are using this suggestion ticket to track any other requests you may have for improvements to the CMake Targets View to meet your CMake needs: CMake Targets View Suggestions – Developer Community (visualstudio.com) Anything else? You can also find us on Twitter (@VisualC) or via email at visualcpp@microsoft.com. To open a bug, please see Visual Studio Feedback. Sinem Akinci Program Manager II, Visual C++ Team Follow

Read More

Learn How To Use Integer Literals And The Deprecated Attribute In C++

Hello fellow C++ Developers. Since January we have released many new posts covering the features of the C++11 standard. These features are mostly done, and this week we start on describing C++14 features. We have five more beginners to professional-level topics in modern C++. C++ evolves and refines itself even further with the release of each new C++ standard. C++14 came with a new deprecated attribute feature to allow marking an entity as deprecated – potentially obsolete and best avoided. We explain what deprecated means and how to use the deprecated attribute in C++. In another post, we explain why the gets function was deprecated in C++11 and eventually removed altogether in C++14. We teach integer literals, and binary literals that come with C++14. There is also a great new feature, digit separators that makes it easy to see integer values in coding, and we explain how to use it in different integer types. Our educational LearnCPlusPlus.org site has a whole bunch of new and unique posts with examples suitable for everyone from beginners to professionals alike. It is growing well thanks to you, and we have many new readers, thanks to your support! The site features a plethora of posts that are great for learning the features of modern C++ compilers with very simple explanations and examples. RAD Studio’s C++ Builder, Delphi, and their free community editions C++ Builder CE, and Delphi CE are a real force for modern application development. Table of Contents Where I can I learn C++ and test these examples with a free C++ compiler? How to use modern C++ with C++ Builder? How to learn modern C++ for free using C++ Builder? Do you want to know some news about C++ Builder 12? Where I can I learn C++ and test these examples with a free C++ compiler? If you don’t know anything about C++ or the C++ Builder IDE, don’t worry, we have a lot of great, easy to understand examples on the LearnCPlusPlus.org website and they’re all completely free. Just visit this site and copy and paste any examples there into a new Console, VCL, or FMX project, depending on the type of post. We keep adding more C and C++ posts with sample code. In today’s round-up of recent posts on LearnCPlusPlus.org, we have new articles with very simple examples that can be used with: The free version of C++ Builder 11 CE Community Edition or a professional version of C++ Builder  or free BCC32C C++ Compiler and BCC32X C++ Compiler or the free Dev-C++ Read the FAQ notes on the CE license and then simply fill out the form to download C++ Builder 11 CE. How to use modern C++ with C++ Builder? C++ is very strong in every aspect of modern programming and evolves and refines itself even further with the release of each new C++ standard. While there are many new additions there are some features that are found not useful or ‘dangerous’ in programming, thus the C++ community offers its deprecation in the next released C++ standard and then it is generally removed in the following standard. C++14 came with a new deprecated attribute feature to allow marking an entity as deprecated – potentially obsolete and best avoided. In the first post, we will explain what deprecated means and how can we use the [[deprecated]] and __declspec(deprecated) attributes in modern C++. Modern C++ has a lot of useful functions […]

Read More

What’s New for the Remote File Explorer in Visual Studio

What’s New for the Remote File Explorer in Visual Studio Sinem Akinci September 18th, 20233 2 The Remote File Explorer gives you the capability to access your files and folders on your remote machines that you are connected to through the Connection Manager in Visual Studio, without having to leave the IDE. Since we last spoke, the team has implemented new features to further enhance your remote file workflows by listening to your direct feedback.  Download the latest preview version of Visual Studio to access the new updates for the Remote File Explorer and give it a try. Background To access the Remote File Explorer, navigate to View > Remote File Explorer after downloading through the Linux and Embedded Workflow in Visual Studio. It will also now automatically open when you open a cross-platform C++ project (vcxproj for Linux or CMake project with at least one configuration in CMake Presets with a remote SSH target). Our initial announcement can be viewed here, which goes into browsing, uploading, and downloading files. To learn more about how to connect to a remote machine through the Connection manager, please see these instructions. Now, you can view and edit these files from Visual Studio, as well as search for files through the top bar. Additionally, with the new enhanced toolbar, you are more empowered than ever to quickly perform actions on your files. Search your Files You can now search through your files and folders on your remote machine using the top bar in the Remote File Explorer. After searching, you can then right-click on any result and select “Go to remote path” to then navigate to that result’s remote path location in the Remote File Explorer. View and Edit your Files The Remote File Explorer now allows you to view and edit files on your remote machine from Visual Studio, just like you would any other file in the Solution Explorer. The Remote File Explorer will also automatically detect if your remote files have any changes that occurred so that you can be certain when in remote workflows. Home and Settings Icons New icons have been added to the toolbar of the Remote File Explorer to make it easier than ever to navigate and perform actions. Clicking the home icon quickly navigates the user back to the root node. Clicking on the settings icon opens the Remote File Explorer settings that allows you to configure your Remote File Explorer. What’s Next? To improve your end-to-end remote workflows, we are planning to further integrate this feature with the Integrated Terminal and other potential remote workflows. We would love to hear from you how you would use this feature to further shape our backlog and other planned enhancements. Please reach out to us via email if you would like to chat or we have an open feedback ticket here. Send us more feedback! We hope the latest updates to the Remote File Explorer will further empower you in your remote workflows. Please let us know your thoughts and any other ideas you may have for the feature. The comments below are open and we also have a Visual Studio Feedback ticket open to track any requests that you can comment on. You can also find us on Twitter (@VisualC) or via email at visualcpp@microsoft.com. To open a bug, […]

Read More