Strings windows wstring

How To Use Gamepad Or Joystick Controller In A C++ Builder FMX App?

C++ is one of the most powerful programming languages that we can use to create games that are playable with mouse, keyboard and gamepads or joysticks. We also use C++ in commerce, industry, in robotics, and in the control of IoT devices. Despite competition from other programming languages the games market is still very much dominated by C++. Many games seek to go beyond keyboards to control the gameplay by using specialized controllers either in addition to or instead of keypresses on the computer’s keys. Two of the most well-known controllers in these areas are joysticks or gamepads. The simplest examples of interfacing with game controllers on Windows is by using the XInput library. Even though XInput has been around for a long time it can still be used with the latest C++ Editor and compiler for Windows. In this post, we explain how you can use gamepad or joystick controller in C++ using with Xinput library. Is there a component for using a gamepad or joystick in C++ on Windows? If you are looking for a component library, there are Delphi and C++ Builder-compatible components built on the XInput library. The Controller library is a Delphi and C++ Builder component that allows applications to receive input from the Xbox Controller. The main features of this library are: Uses Windows XInput API Available for Delphi and C++ Builder from versions 6 right up to the current modern version 11. Source code included in the registered version. Royalty-free distribution. You can download the trial version of the XInput library, or you can buy a professional edition from here. How can I control a gamepad or joystick in C++ with Xinput Library? XInput library is deprecated but is still a supported library by Microsoft. They recommend moving towards the GameInput library or Windows.Game.Input for Windows applications. If we look at these kinds of libraries (i.e GamePad.h library), like MS’ own DirectXTK, we can see that the toolkit allows one to define USING_XINPUT vs. USING_GAMEINPUT vs. USING_WINDOWS_GAMING_INPUT to pick which underlying library is used. If we compare  XInput compared to GameInput: XInput library is old and easy to implement Windows applications. XInput library is limited to 4 controllers XInput library has no uniform interface to other input (like mouse/keyboard) XInput library occurs with higher latency XInput library is not friendly with other controllers. i.e. no support for Xbox One Rumble Motors. Briefly, DirectInput is better than XInput. If you still want to use XInput, you can check more about https://learn.microsoft.com/en-us/windows/win32/xinput/getting-started-with-xinput XINPUT_GAMEPAD structure (declared in ) is explained here : https://learn.microsoft.com/en-us/windows/win32/api/xinput/ns-xinput-xinput_gamepad As in there, this structure has these members: wButtons, bLeftTrigger, bRightTrigger, sThumbLX, sThumbLY, sThumbRX, sThumbRY. Here wButtons member is used as a bitmask of the device digital buttons, it can be used as below, wButtons Device digital button flags Gamepad Bitmask XINPUT_GAMEPAD_DPAD_UP 0x0001 XINPUT_GAMEPAD_DPAD_DOWN 0x0002 XINPUT_GAMEPAD_DPAD_LEFT 0x0004 XINPUT_GAMEPAD_DPAD_RIGHT 0x0008 XINPUT_GAMEPAD_START 0x0010 XINPUT_GAMEPAD_BACK 0x0020 XINPUT_GAMEPAD_LEFT_THUMB 0x0040 XINPUT_GAMEPAD_RIGHT_THUMB 0x0080 XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100 XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200 XINPUT_GAMEPAD_A 0x1000 XINPUT_GAMEPAD_B 0x2000 XINPUT_GAMEPAD_X 0x4000 XINPUT_GAMEPAD_Y 0x8000 How to use a gamepad or joystick in a C++ Builder FMX application? Here are the steps to use gamepad or joystick in C++ Builder FMX app, Create a new Multi-Device C++ Builder FMX application Drag a Timer (TTimer) component on to Form In Object Inspector window, set its interval to 15 and be sure it is enabled Drag a shape Circle (TCircle) component on to Form In Object […]

Read More

How To Change Background Color Of A Component In An FMX C++ App

C++ Builder is the easiest and fastest C++ IDE for building professional applications with powerful GUI components like Memo, Edit, ListBox, StringGrid and many more. Each component can be ‘skinned’ with Styles to change their visual appearance. Styles are very powerful and because of this it can sometimes take a little to get used to how they work. In this post, we explain how to change background color of a component. Here is how you can do, How can I change background color of a component using styles in an FMX app? Syles are sets of graphical details that define the look and feel of an application visually and they are one of most beautiful and useful UI features of RAD Studio. Styles make your UI elements have a professionally designed appearance with minimum effort from you. Official Styles are designed by Embarcadero’s professional graphic designers. There are also other 3rd party Styles; also, users may generate their own styles. Styles are similar to themes in Windows or skins of old-style applications like WinAmp – but brought right up to date for the modern world. In RAD Studio, Multi-Device C++ Builder FireMonkey Projects, using styles on your new projects is very easy. You design your application’s screens in normal ways with buttons, labels, edit boxes, memos, trackbars, panels, switches etc. These controls will automatically adopt whatever appearance is enabled by the chosen style. You can also add these Styles to your Old C++ Builder Projects or to Old C++ Builder Unit files. You just need a RAD Studio, C++ Builder version which supports styles. We highly recommend you use the latest RAD Studio or C++ Builder versions which have new features and improvements on Styles. Here is how you can use Styles. In addition, you can create your custom styles in RAD Studio and C++ Builder. Here are two examples about Memo (TMemo) and Edit (TEdit) components. How to change background color of an FMX component in C++ code? Here is a simple function example to change background color of a component in C++, 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 void SetBackgroundColor(TStyledControl *control, TAlphaColor color) {   control->NeedStyleLookup();   control->ApplyStyleLookup();   TFmxObject *fmxobj = control->FindStyleResource(“background”);   TRectangle *rect = new TRectangle(fmxobj);   fmxobj->AddObject(rect);   rect->Align = TAlignLayout::Client;   rect->Fill->Color = color;   rect->Stroke->Color = claNull;   rect->HitTest = false;   rect->SendToBack(); } Is there a full C++ example of how to change the background color of a component in FMX and C++? In this example there are Memo, Edit, ComboBox, ListBox components and a Button component. You need to create a new C++ Builder Multi-Device application and then you should drag these components on your form. You can choose your colors from here https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Colors_in_FireMonkey If you want to know more about colors in Modern C++ here are some examples of how to use RGB or ARGB colors in C++. After that, you can modify your code as below. Here is a full C++ example of to change the background color of a component in an FMX C++ application. 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 #include #pragma hdrstop #include “Component_Background_Color_Unit1.h” //————————————————————————— #pragma package(smart_init) #pragma resource “*.fmx” TForm1 […]

Read More

How To Change Background Color Of An Edit In An FMX C++ App

C++ Builder is the easiest and fastest C++ IDE for building everything from simple to professional applications using visually amazing GUI controls and forms. Each form and component can be skinned with Styles which allow your application to have its own professionally designed attractive look and feel. The Style systems of the VCL and FMX (FireMonkey) award-winning frameworks is very easy to use but there is sometimes a learning curve to climb to understand how to get the best out of them. In this post, we explain how to change background color of an Edit (TEdit) which is one of the most frequently asked questions. These methods below, can be applied to other components too. How to change the background color of an Edit control using Styles? Styles are sets of graphical details that define the look and feel of an application visually. They are one of most beautiful and useful UI features of RAD Studio, that makes your UI elements ‘skinned’ with a professionally designed graphical look and feel. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps (not wrapped in some kind of runtime interpretation layer) and the powerful FireMonkey (FMX) framework for cross-platform UIs. Both VCL and FMX apps support Styles. There are many different styles available, and they cater for almost every possible taste in aesthetics as well as providing dark and light mode versions. More details about Styles can be found here. You can also find additional Premium Styles here. If you want to learn how you can modernize your components with styles here is the post you need; Right-click on the Edit and select ‘Edit Custom Style…’ Expand Edit1Style: you’ll see the background node. Click on background to select it. Then add a TRectangle via the Palette. The IDE should expand the background node and show a new Rectangle1Style tied to the TRectangle, Via the Object Inspector change the Color of TRectangle Click on the Apply Style button in the ‘Style Designer’. Compile and run your application If you still have problems to set color, may be this docwiki can help you : https://blogs.embarcadero.com/edit-custom-style-to-change-the-background-color-of-a-fmx-tedit/ How to change background color of an Edit in C++ code? If you want to change the background color of a Edit component (TEdit) in C++ Builder, first you should set the StyleLookup property to “Editstyle” as below.   Edit1->StyleLookup = “Editstyle”;   If you look at the Custom Style of Edit, there is “background” property, so we should find this resource by using the FindStyleResource() method of Edit as given example below.   Edit1->StyleLookup = “Editstyle”; auto fmxobj = Edit1->FindStyleResource(“background”, false);   if this resource object found, we can create a rectangle (TRectangle) as a background as below.   std::unique_ptr rect(new TRectangle(fmxobj));   Here we used unique_ptr which more modern to create this rectangle. Now we can set properties of our Rectangle, including its color.   rect->Align = TAlignLayout::Client; rect->Fill->Color = color; rect->Stroke->Color = color; // = claNull; rect->HitTest = false; rect->SendToBack();   Now, at last we need to add this object by using .get() method of unique_ptr. And the final trick here is you must release this unique_ptr by using .release() otherwise it doesn’t have any effect.   fmxobj->AddObject(rect.get()); rect.release();   I asked one of Embarcadero’s engineers to explain this a little more to me and he noted that “If you insist on using unique_ptr, you must add a call to .release(); to tell the unique_ptr that you no longer want it to clean up […]

Read More

How To Use Gamepad Or Joystick Controller In A C++ Builder VCL App?

C++ is one of the most powerful programming languages that we can use to create games that are playable with mouse, keyboard and gamepads or joysticks. We use C++ not just in games but also in almost every kind of industry, in robotics, and in the control of IoT devices. Games frequently have better playability if the user can control the game with input devices other than keyboard. The most popular controllers for games are gamepads and joysticks. One of the simplest ways to use such game controller hardware on Windows is using the venerable XInput library. Despite XInput having been around for a long time it can still be used with the latest C++ IDE and compiler for Windows. In this post, we explain how you can use gamepad or joystick controller in C++ using with Xinput library. Is there a ready-made component for controlling a gamepad or joystick in C++ on Windows? If you are looking for a component library, there are Delphi and C++ Builder-compatible components built around the XInput library. The Controller library is a Delphi and C++ Builder component that allows applications to receive input from the Xbox Controller. The main features of this library are, Uses Windows XInput API. Available for Delphi/C++ Builder 6 – 11 and Lazarus 2.0.12 Source code included in the registered version. Royalty free distribution. You can download the trial version of the XInput library, or you can buy a professional edition from here. How can I control a gamepad or joystick in C++ with the Xinput Library? XInput library was developed quite some time ago and is a deprecated but still supported library by Microsoft. They recommend moving towards the GameInput library or Windows.Game.Input for Windows applications. If we look at these kinds of libraries (i.e GamePad.h library), like MS’ own DirectXTK, we can see that the toolkit allows one to define USING_XINPUT vs. USING_GAMEINPUT vs. USING_WINDOWS_GAMING_INPUT to pick which underlying library is used. If we compare  XInput compared to GameInput: XInput library is easy to implement Windows applications. XInput library is limited to 4 controllers. XInput library has no uniform interface to other input (like mouse/keyboard). XInput library occurs with higher latency. XInput library is not friendly with other controllers. i.e. no support for Xbox One Rumble Motors. In brief, DirectInput is better than XInput. If you still want to use XInput, you can check more about https://learn.microsoft.com/en-us/windows/win32/xinput/getting-started-with-xinput XINPUT_GAMEPAD structure (declared in ) is explained here: https://learn.microsoft.com/en-us/windows/win32/api/xinput/ns-xinput-xinput_gamepad In there, this structure has these members: wButtons, bLeftTrigger, bRightTrigger, sThumbLX, sThumbLY, sThumbRX, sThumbRY. Here wButtons member is used as a bitmask of the device digital buttons, it can be used as below. wButtons Device digital button flags Gamepad Bitmask XINPUT_GAMEPAD_DPAD_UP 0x0001 XINPUT_GAMEPAD_DPAD_DOWN 0x0002 XINPUT_GAMEPAD_DPAD_LEFT 0x0004 XINPUT_GAMEPAD_DPAD_RIGHT 0x0008 XINPUT_GAMEPAD_START 0x0010 XINPUT_GAMEPAD_BACK 0x0020 XINPUT_GAMEPAD_LEFT_THUMB 0x0040 XINPUT_GAMEPAD_RIGHT_THUMB 0x0080 XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100 XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200 XINPUT_GAMEPAD_A 0x1000 XINPUT_GAMEPAD_B 0x2000 XINPUT_GAMEPAD_X 0x4000 XINPUT_GAMEPAD_Y 0x8000 How to use a gamepad or joystick in C++ Builder VCL Application? Here are the step to use gamepad or joystick in C++ Builder VCL app, Create a new VCL Windows application in C++ Builder. Drag a Timer (TTimer) component onto the Form. In the Object Inspector window, set its interval to 15 and be sure it is enabled. Drag a Shape (TShape) component on to Form. In Object Inspector window, set its Shape property to stCircle, change Brush color something that makes you happy. Double click to […]

Read More

Advantages and Disadvantages of The C++ Programming Language

In the last 40 years C++ has earned, and maintained, a reputation as one of the most efficient programming languages. C++ is still hugely popular, often in the top 3 of any lists of popular programming languages and is used widely across a wide array of operating systems. Choosing the right programming language and IDE (we call them C++ tools) are very important in the early stages of learning to program. Generally, new developers want to know the advantages and disadvantages of the C++ programming language, and in this post, we try to explain its pros and cons for you. What are the pros and cons of C++ programming language? What are the advantages of C++? 1. C++ is compiler-based with very fast execution times C++ is a compiler-based programming language and that helps make it the fastest and one of the most powerful programming languages. This is one of the reasons to use hardware and software algorithms efficiently. In general, there are two types of programming languages: Interpreted and Non-Interpreted (Compiled). All computers work with something called machine code (code that can be directly executed by the computer’s CPU) that tells the computer what to do. This is the most native and fastest code, but it requires writing many lines for even quite simple things and is hard to generalize for all kinds of machines. It’s also not very easy to understand for humans. A compiler (C or C++ Compiler, etc.) is a computer program that converts a program written in a ‘high level’ programming language such as C++ code into executable machine code. The high-level language looks more like English and is much easier to understand and less complicated. 2. C++ is a structured and object oriented programming language C++ allows developers to use C language which is a structured programming language and it also allows Object Oriented Programming. Object Oriented Programming (OOP) is a way to integrate with objects which can contain data in the form of attributes or properties of objects, and code blocks in the form of methods, and functions of objects. These attributes and methods that belong to the class are generally referred to as class members. Object-Oriented Programming is a good way to work on data and work with functions in memory. Classes and Objects are the best way to work on properties and functions. Object-Oriented Programming has many advantages over procedural programming and it is the most characteristic feature of the visual and modern C++ programming language. 3. C++ supports visual 2D, 3D and GUI-based programming C++ is useful to make GUI-based applications on Windows, iOS, Android, Mac OS, Linux, and many other less popular OSes. C++ has different GUI frameworks i.e. VCL, FMX, GTK, and other Visual components. Modern C++ has been enhanced with Visual Bindings, High-DPI 4K supports, responsive features, skinned UI elements, glamorous one-click GUI sets, 2D and 3D components like OpenGL, Skia, and Viewport3D; and has many game engines like Unreal Engine, Unity, O3DE. C++ is also useful to develop graphical 2D and 3D applications, real-time computational simulations, and analysis, C++ highly uses CPU and GPU-based applications with graphical supports like Physics, OpenCL, Vulkan, HPC, etc. 4. C++ is a mid-level programming language with low-level capabilities Because of its capability in assembly-level coding and compiling abilities, I prefer calling C a ‘close to low-level language’. Briefly, we may say C and C++ languages are close […]

Read More

How To Use Base-8 (Octal) Numbers In Modern C++?

In general, in nearly all programming languages, including Modern C++, we use base-10 numbers, while our computer hardware uses the binary base-2 system (bits). I personally believe that base-10 is because we typically have 10 fingers and since we learn to counting on our fingers we use base-10 primarily. However, due to the way binary works it is sometimes convenient to use base-8 system octal (oct) and base-16 system hexadecimal (hex) numbers in programming. In this post, we explain how to use Base-8 octal numbers in Modern C++. What is the octal number system? The octal – or oct – number system is the base-8 system, Octal uses the digits from 0 to 7. In general, we use a base-10 number system in normal life. In the digital world we also use base-2, base-8, and base-16 as well as base-10. If you want to explore the different numbering systems, try this Wikipedia article. Let’s give some octal examples and their values in the decimal system, 1octal  = 1 10octal  = 8 100octal = 64 How to declare base-8 (octal) number in modern C++? In C++, when we use octal numbers in C++ code, we put 0 on the left side of an octal number. This zero shows it is an octal representation. int x; // 015 in octal is 13 base10 or decimal x = 015; How to initialize base-8 (octal) number in modern C++? here the first zero on the left side of 0010 defines this number representation is an octal representation. The integer x value is results as 8; How to set an integer to base-8 (octal) number in modern C++? We can use std::istringstream() which is declared in library. Here Octal number “010” is declared into x as a octal number, now when you print this variable, it will be displayed in octal decimal system,    int x;    std::istringstream(“010”) >> std::oct >> x;    std::cout << x << std::endl; How to print out base-8 (octal) number in modern C++? When we print out base-8 (octal) numbers we use std::oct format as below, int x = 0010; std::cout << std::oct << x << std::endl; How to print out base-8 (octal) number in C language? C has very powerful printf() function and there is a ‘%o‘ Format Specifier to print out octal numbers. How to display base-8 (octal) number in C++ Builder? C++ Builder is using UnicodeString in most of components, and UnicodeString very powerful printf() method. There is a ‘%o‘ Format Specifier to print out octal numbers that can be used as below, int i = 64; // decimal UnicodeString ustr; ustr.printf(“%o n”, i); Edit1->Text = ustr; How to convert base-8 (octal) number to (base-10) decimal number in modern C++? When you declare an integer with octal representation, it is automatically converted to base-10 number. For example: here a = 8 in the decimal system. there is another method std::stoi that converts octal representation in string to an integer. Here is an example, int x = std::stoi(“011”, 0, 8); std::cout << x << std::endl; How to convert (base-10) decimal number to base-8 (octal) number in modern C++? In C++, computation is done in base-2 while you have a decimal number. If you want to convert base-10 decimal number to base-8 octal number, you only need to convert to a octal number or string when you […]

Read More

What Are Declared True Constants In Modern C++?

C++ has many different variable types to develop modern applications with modern C++ IDE‘s and compilers. Several different language constructs are referred to as ‘constants’. There are numeric constants and string constants. Every enumerated type defines constants that represent the values of that type. Declared constants are either true constants or typed constants. In this post, we will explain what we mean by a declared constant and what is a true constant which is a kind of declared constant in C++. What are declared constants in Modern C++? Several different language constructions are referred to as ‘constants’. There are numeric constants (also called numerals) like 17, and string constants (also called character strings or string literals) like ‘Hello world!’. Every enumerated type defines constants that represent the values of that type. There are predefined constants like True, False, and nil. Finally, there are constants that, like variables, are created individually by declaration. Declared constants are either true constants or typed constants. There are predefined constants like True, False, and nil. Finally, there are constants that, like variables, are created individually by declaration. These two kinds of constant are superficially similar, but they are governed by different rules and used for different purposes. What are true constants in Modern C++? A true constant is a declared identifier whose value cannot change. The syntax for declaring a true constant is: const identifier = constantExpression; For example: declares a constant called MaxValue that returns the integer 237. Where identifier is any valid identifier and constantExpression is an expression that the compiler can evaluate without executing your program. If constantExpression returns an ordinal value, you can specify the type of the declared constant using a value typecast. For example: const MyNumber = Int64(17); declares a constant called MyNumber, of type Int64, that returns the integer 17. Otherwise, the type of the declared constant is the type of the constantExpression. If constantExpression is a character string, the declared constant is compatible with any string type. If the character string is of length 1, it is also compatible with any character type. If constantExpression is a real, its type is Extended. If it is an integer, its type is given by the table below. Types for integer constants Range of constant (hexadecimal) Range of constant (decimal) Type Aliases 0 $FF 0 255 Byte UInt8 0 $FFFF 0 65535 Word UInt16 0 $FFFFFFFF 0 4294967295 Cardinal UInt32, FixedUInt 0 $FFFFFFFFFFFFFFFF 0 18446744073709551615 UInt64 -$80 $7F -128 127 ShortInt Int8 -$8000 $7FFF -32768 32767 SmallInt Int16 -$80000000 $7FFFFFFF -2147483648 2147483647 Integer Int32, FixedInt -$8000000000000000 $7FFFFFFFFFFFFFFF -9223372036854775808 9223372036854775807 Int64 32-bit native integer type Range of constant (hexadecimal) Range of constant (decimal) Type Equivalent type -$80000000 $7FFFFFFF -2147483648 2147483647 NativeInt Integer 0 $FFFFFFFF 0 4294967295 NativeUInt Cardinal 64-bit native integer type Range of constant (hexadecimal) Range of constant (decimal) Type Equivalent type -$8000000000000000 $7FFFFFFFFFFFFFFF -9223372036854775808 9223372036854775807 NativeInt Int64 0 $FFFFFFFFFFFFFFFF 0 18446744073709551615 NativeUInt UInt64 32-bit platforms and 64-bit Windows integer type 32-bit platforms include 32-bit Windows and Android. Range of constant (hexadecimal) Range of constant (decimal) Type Equivalent type -$80000000 $7FFFFFFF -2147483648 2147483647 LongInt Integer 0 $FFFFFFFF 0 4294967295 LongWord Cardinal 64-bit platforms integer type excluding 64-bit Windows 64-bit platforms include 64-bit iOS, 64-bit Android, 64-bit macOS and 64-bit Linux. Range of constant (hexadecimal) Range of constant (decimal) Type Equivalent type -$8000000000000000 $7FFFFFFFFFFFFFFF -9223372036854775808 9223372036854775807 LongInt Int64 0 $FFFFFFFFFFFFFFFF 0 18446744073709551615 LongWord UInt64 Here are some examples of constant declarations: 1 2 3 4 5 6 7 8 […]

Read More

How To Run A C Or C++ Program On iOS

A fast and reliable C and C++ Compiler and IDE for app development software for iOS is very important for beginners and professionals alike, whether they are developing C++ for iOS or for any of the other operating systems and targets. The C and C++ programming languages are subjectively the World’s most powerful programming languages and consistently appear in the World’s top three most popular programming languages. Thanks to its huge range of ready-made variables, functions, methods, namespaces and libraries it’s the do-everything toolkit which can be used for everything from regular simple apps to low-level operating system drivers, IoT hardware control and everything in between. When a user wants to develop modern C++ applications, she or he will benefit from investing a very small amount of time in becoming familiar with the functions, features and shortcuts of a professional IDE. A small effort in that area pays dividends in productivity. In this post we explain basic of using C++ Builder to create an iOS app as a guide for beginners. What is a good IDE for creating a C++ program for iOS? Do you know that you can develop C/C++ iOS Apps on Windows 11 with the latest RAD Studio / C++ Builder? C++ Builder supports all C commands and CLANG LLVM, C++ 17 standards. RAD Studio with C++ Builder and Delphi is a great IDE and compiler running on Windows that supports multi-device applications for different platforms including iOS and you can develop native ARM applications for M1 Silicon CPUs used in the latest Apple hardware too. So, your application’s program code can be recompiled so that it runs on everything from the latest Windows 11 version as well as on Apple ‘desktop’ devices such as the MacBook laptops, Mac Minis and iMacs using either Intel processors or the new M1 ‘Silicon’ CPUs. Yet that same program code can almost entirely be reused with little or no changes so it may be compiled for iOS where your apps can run on the very latest iPhone devices. Everywhere your users are, your C++ and Delphi apps can be. In my opinion, because of its multi-device application and great tools of IDE, C++ Builder is the best C++ IDE Software and the best CLANG-based compiler that supports multi-device applications for all your needs including professional iOS application. How to create and run a C++ Program for iOS with the RAD Studio IDE and C++ Builder? C++ Builder is the easiest and fastest C and C++ IDE for building simple or professional applications on the Windows, macOS, and iOS operating systems. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. C++ Builder comes with Rapid Application Development Studio, also known as RAD Studio. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs. There is a free C++ Builder Community Edition for students, beginners, and startups. More details about C++ Builder & RAD Studio for the beginners can be found in Official Wiki of Rad Studio. You can download the free C++ Builder Community Edition here: https://d-data.ro/product/c-builder-in-romania//starter.Professional developers can use the Professional, Architect or Enterprise versions of C++ Builder. Please visit https://d-data.ro/product/c-builder-in-romania/. See What’s New in RAD Studio 11 Download […]

Read More

What Is Defaulted Function or Method In Modern C++ Now?

Modern C++ is really amazing with a lot of great features of programming. One of the features of Modern C++ is a Defaulted Function or in another term Defaulted Method of classes that is a function that contains =default; in its prototype. Defaulted functions are a feature of C++11 and above. In this post, we explain what is a defaulted function or method in modern C++. What is defaulted function or method in Modern C++? A defaulted function (actually defaulted method, they are functions in classes) is a function that contains =default; in its prototype. This construction indicates that the function’s default definition should be used. Defaulted functions are a C++11 specific feature. If you have a method (including construction method) and you want to make it defaulted method, just add ‘=default;’ specifier to the end of this method declaration to declare that method as an explicitly defaulted method (or explicitly defaulted function). Is there a simple example of a defaulted function or method in modern C++? Here is an example to demonstrates defaulted function:  class Tmyclass {         Tmyclass() = default;                    // OK }; This will allow the compiler generate the default implementations for explicitly defaulted methods which are more efficient than manually programmed method implementations.  Here is another example class. class A {         A() = default;                    // OK         A& operator = (A & a) = default;  // OK         void f() = default;               // ill-formed, only special member function may default }; What is defaulted function or method in Modern C++? For example, if we have a parameterized constructor, we can use the ‘=default;’ specifier in order to create a default method. Because the compiler will not create a default constructor without this. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 #include   class Tmy_class { public:   Tmy_class(int x) // parameterized constructor { std::cout

Read More

How To Use C++ Standards In C++ Compiler Options

C++ is a very decent programming language that has a very strong compiler supported by a big community on a range of different platforms. The C++ language definitions, syntax, and functionality are organized into different standards. Those standards are usually named after the year the standard was adopted such as 1998 for C++98, 2011 for4 C++11, 2014 for C++14, and 2017 for C++17. One of the great features of a C++ compiler is you can choose which standards you want your code to be compiled against, before the compilation of your source code. This allows the compiler to check that your code complies with that standard. In this post, we explain what the standards are, how you can view them, how you can check the compatibility of your C++ source code against different standards, and how you can choose to use C++ standards in C++ compiler options. What is a C++ standard? Standards are an international agreement for C++ compilers, made by the IDE and compiler developers of different operating systems (Embarcadero C++ Builder, Microsoft MSVC, GNU GCC, Apple Swift, etc.). They are formal, legal, and very high-level detailed technical documents intended primarily for people writing C++ compilers and standard library implementations.  The current available standards and some of their key features are listed below. How to use C++ standards in C++ compiler options? When we use ‘-std=’ option in a C++ compiler this option type enables or disables some features. We need to use these features to see the effect of each C++ standard option. Personally, I always prefer to use the latest version of the standards in my compilers. However, when programming, sometimes you may have to work on old or legacy C++ source, or you may be programming to another company that uses older standard compilers. Or maybe you just want to check if your code is compatible with a particular standard, or the code uses new standards. At these times, you can use std option in C++ compilers. In general, we can use the -std option to compile to a particular C++ standard. Here are some option examples, -std=c++98 -std=c++11 -std=c++14 -std=c++17 -std=c++20 or -std=c++2a For example, if you want to compile your code with C++11 features, you can use C++ Builder 64bits command line compiler as shown below: bcc64 –std=c++11 myapp.cpp –o myapp For an example, we can write this C++ code below which uses a feature found in the C++17 standard and above. int main() {   static_assert(sizeof(int)==4); // C++17 feature     return 0; } If you are using the C++17 compiler, this code will be compiled successfully because the static_assert feature comes with C++17. If you compile this code with -std=c++11 or -std=c++14 options this time you will get warning which is telling you that you have requested C++ standard version 11, but there is a feature that requires C++ standard version 17 (Until C++17, a message was required w/ static_assert). How to use C++ standards in the C++ Builder compiler options? In C++ Builder CLANG compiler, we can use -std option to compile in previous standards. This option can be used in bcc32c and bcc64, both support these std options below, -std=c++11 -std=c++14 -std=c++17 I should note that, C++11 and C++14 options are partially supported, these options do not have a STL that works with all, so you have the latest STL one for C++17. According […]

Read More