Backend C Compiler
VbaCompiler for Excel translates VBA code into C code and calls the C language compiler at the next stage of the compilation. The backend C compiler conducts the compilation of C language source code into Windows DLL file.
The VbaCompiler uses MinGW GCC compiler by default, because this compiler is included into the product installation and deployed together with the VbaCompiler.
Since version 1.9 of the VbaCompiler for Excel, you may use another C compiler–the Microsoft Visual C compiler–as the backend C language compiler of choice. Selection of the backend C compiler is available for the product that is registered with the Professional license.
Microsoft Visual C compiler is not distributed inside the product installation package by default, so in order to switch to it you need to download and install it on your computer by yourself.
The Microsoft Visual C compiler is supplied as a part of the Microsoft Visual Studio (frequently shortened to MSVS) suite, and it comes provided with all of the files and libraries that you may need.
Microsoft Visual Studio has multiple editions and some of them are paid.
You need one edition in particular– Visual Studio Community Edition– which is absolutely free of charge. To find out whether you meet the requirements for the Visual Studio Community edition you may look through the requirements on the official page:
https://visualstudio.microsoft.com/vs/community/
In short – the Visual Studio Community Edition you may use is free if you happen to be an individual developer or your company has an annual revenue less than 1 million US dollars.
Download the Microsoft Visual Studio Community Edition here:
https://visualstudio.microsoft.com/downloads/
During the installation, you need to select the “Desktop Development with C++” checkbox
And at least two options on the right-side of the installation details tree – “MSVC v142” or higher (which stands for Microsoft Visual C Compiler) and Windows SDK.
The VbaCompiler for Excel can use Visual C compiler version 14.2 (mentioned as MSVC 142 in the options) and higher.
When you have finished installing and are ready to select the MSVC as your backend compiler, you need to indicate the path to the MSVC in the preferences of the VbaCompiler for Excel.
To do that you need to run VbaCompiler for Excel and follow the Preferences menu item in the VbaCompiler main menu, the following window will be opened:
You need to click on the “Select” button in order to select the folder where the MSVC is located.
If you have installed the MSVS 2022 or higher, then you need to search the Visual Studio location in your “Program Files” folder on your system disk drive. So, it may look like the following image:
You need to select the first folder under “Microsoft Visual Studio”—which is usually the year which denotes the version of MSVS—and VbaCompiler for Excel will find the exact Visual C compiler folder by itself.
In the most cases the Visual C generated code is a better optimized and more robust binary code for the Windows Operating System than the binary code that is generated by the MinGW GCC default C language compiler.
When you install the Microsoft Visual C compiler on your computer, and you have the VbaCompiler for Excel registered with Professional license then you may select the option that switches to the Microsoft Visual C as your backend C compiler.
The Visual C compiler has different optimization options from those that the MinGW GCC C compiler uses.
Here is a short list of the Visual C optimization options:
– O1 sets a combination of optimizations that generate minimum size code.
– O2 sets a combination of optimizations that focuses on maximum speed for the resulting code.
– Od disables optimization, which can be used to speed up compilation and simplify debugging.
– Oi generates intrinsic functions for appropriate function calls.
– Os tells the compiler to favor optimizations for size over optimizations for speed.
– Ot (the default setting) tells the compiler to favor optimizations for speed over optimizations for size.
– Ox is a combination option that selects several of the optimizations with a particular emphasis on speed. /Ox is a strict subset of the /O2 optimizations.
– Oy suppresses the creation of frame pointers on the call stack for quicker function calls.