C++ Compilers
Its been a while since I've written on here, nearly a year. In that time I have finished the masters program at Penn State University in software engineering. This fall, I will begin a PhD at Robert Morris University.I have been spending a fair amount of time fiddling around since I finished the Masters program in December, primarily with ham radio and brushing up on my C++.
A lot has changed since I took a C++ class back in highschool. Back then we were using C++98, and Eclipse. Up until quite recently I recall having a fair amount of trouble getting Eclipse to cooperate with compilers when I wanted to get back into programming. I believe I made a few attempts from 2010-2020. At the time I became quite frustrated that there wasn't “one way” to do things. I also think I would of had an easier time had I not been on a 5+ year old macbook and on a windows machine. As of quite recently I learned that Microsoft's Visual Studio offers a few different benefits, but the primary one is ease of getting started.
In my efforts to get back into C++ recently, I read through A Tour of C++. This text touts a bunch of great new modern features, and that all C++ developers should start using the new features whenever possible. One of the features that has my attention is “modules”. Someday, C++ programs will no longer need header files and they can use modules which allow faster compile time.
Frustrated by all the boilerplate involved with header files, I was eager to try making my own module or two and seeing if it was an improvement. I cracked open my linux laptop and stumbled around the internet for a bit to determine what I needed to do to actually implement a module. From what I mustered I needed a main.cpp file and the module could live in an .ixx file or .cppm file or .mpp file.
Quite a few different options...hm.
After much fiddling on my Linux laptop with both GNU Compiler, and Clang with various IDES including CLion, Eclipse, and CodeBlocks. I could not get a program using a module to compile. I tried various flags, configurations, etc. I did get cmake to build a project via the command line, but my knowledge of CMake is quite novice and I couldn't figure out where to go from there.
After snooping around the internet, I found other folks were able to use modules. They even claimed they could use them with GNU Compiler and Clang. I was, and to some extent, still am perplexed and skeptical of these claims. Further investigation will need done. However, I suspect they are using windows machines.
What I did find to work, quite easily and quite well, was to whip out my neglected Windows 11 machine and download Visual Studio. I had seen whisperings that the “MVSC” (Microsoft Visual Studio Compiler?) aligned with the latest C++ standards, so I figured I'd give it a shot.
After downloading and installing Visual Studio, I had no problem building a small proof of concept program that utilized modules. I put a basic print out “hello world” statement inside of a module and called the function from the main.cpp file.
I was flabbergasted. How had GCC and Clang not implemented this but Microsoft had? Does all modern C++ development take place on Windows? More research is required, but I just tried in XCode on my Mac, and once again I am met with errors such as “Unknown type name 'import'”.
This has me wondering, how can modern C++ proliferate if it is limited to one compiler and ecosystem? Perhaps that is all it needs, but I come from a world of linux machines running web applications. I guess my point is, I hope the other compilers will support more modern C++ practices soon.