C++ Questions

Pages: 1... 910111213
Hey G, I observe (after some years now, lol) that you know VS very well.

I never used it much because it was too heavy on my old Windows box, and I always found it clunky anyway. You’ve had good experiences with it, I presume?

Do you have any other editors you tend to prefer, or is VS it?
I have been dinkin' around with VS since VS 6 in an AMD 1Ghz single core Win9X box. I really started enjoying the VS experience with VS 2015 when MS started making the beast IDE available in a free Community edition. VS used to be rather clunky and twitchy before 2015 in my experience. The older express editions were rather lacking in features as well.

I can't say I know VS all that well, to be perfectly honest. What I do is poke my nose around in the IDE options and online when someone mentions some feature they wonder about.

I have tried other IDEs and still prefer VS for my main hobbyist development platform. I've used Code::Blocks, Orwell's Dev C++, Delphi and C++Builder mostly. Yes, all IDEs. I know I should broaden my horizons to using CMake and command-line code smashing, but I guess I'm lazy. MSYS2 is waiting to be installed again some day.

If someone is going to program on a Windows machine they can't go too wrong using VS. Especially if creating WinAPI GUI apps is something being done.

I'm discovering more and more features I never knew were available. Sorting and removing/adding headers is something very recent.

The Visual Studio Marketplace is a great place to find useful extensions for VS.


I am on a quest for learning C++20 and C++23. Even now VS is the only C++20 100% compliant compiler. The formatting library, modules, etc. Though that gap is closing with the others.

Sadly no one is 100% for C++23.

I shudder to think what C++26 compliance will be when that is formally adopted.

My main development machine is an oooooold Intel Core i5 2400 @ 3.10GHz 4 core with 12GB of DDR3 with a NVIDIA GeForce GT 1030 2GB display adapter. A primary boot SDD of 1TB (931GB actual) and a secondary HDD of 4TB (3.6TB actual). Win 10 Pro to bind them all in the darkness. All crammed into a recycled HP box. One of the old "sits on the desktop on its side" type. The secondary HDD is where I installed most of VS, though there are parts required to be installed on the primary boot drive.

Oh, no floppy drive, have one available by USB if needed, several USB 2 ports, a BD-RE WH16NS40 optical drive internal and a home network that lets me share the internet gateway and provide home wi-fi to connect my 3 PCs.

My other two PCs are tower types. Win 10 and i5. One is x64, the other x86. All 3 are recycled boxes and parts I've added and upgraded over the years.

My main text editor is Notepad++. Useful for a quick look at a code file without firing up VS.

I am first and foremost a programming hobbyist. I am not now nor ever will be a professional programmer. I know C barely, am semi-fluent in C++ and WinAPI. Python, Java and other languages, nada. Mostly due to lack of interest.

I tend to concentrate on avoiding most of the "new shiny object" frameworks people praise. C#, .NET. Ick.

Learning multi-media frameworks like DirectX, SDL2 or SFML are on my to-do list, eventually. When I get that proverbial round to-it.

I am a forcibly disabled, medical retired and crotchey old fart. I don't mellow with age like a fine wine, I am a cheap vino that turned to vinegar. Self-teaching myself programming is both a fun hobby and a way to keep the mind from getting duller than a butter knife.

Maybe that is why my cat and I get along so well, he's as ornery as me.
Dúthomhas: VS much?

George P: <life story>

Dúthomhas: ...

Similar story here.

I’ve dinked with a fair few languages and frameworks. Started out when I was 11-ish writing x86 assembly to link into my GW-BASIC programs so I could play with Mode X (VGA graphics mode) to write games (on the family 8088). My Dad found me doing that and said, “Hold on, son, forget BASIC, here’s a copy of TP4”, and my life changed.

I think a large part of my growth as a programmer occurred in University when I had to learn Scheme — learning to think of things from a functional-language POV vastly improved my ability to reason about code.

Lemme think, MIPS assembly, x86 assembly, BASIC (at least a handful of different flavors, including VBS), FORTRAN, Pascal, Object Pascal, C (and variants, like C--), C++, Java, JS, Scheme/Racket, Haskell, Tcl/Tk, uh... I’m sure I’m forgetting all kinds of weird stuff that I don’t care about anymore... Oh, DOS Batch and bash/csh/sh (can’t stand Powershell)...

Object Pascal remains one of my favorite languages, but both C and C++ has grown on me quite a lot over the years. These days most everything I do winds up being in C, C++, or Tcl.

I like cats, but I have dogs, lol.

When I lived in NM I was staying in a trailer home and the toilet stopped working. The owner didn’t mind my investigating, and I couldn’t get it fixed with either your standard plumbing snake or a high-powered industrial one the owner loaned me, so I wound up pulling the toilet up (and finding someone had thrown a disposable razor down the toilet, which would explain why it backed up so often when we moved in)

<takes a breath>

And also discovered the floor was about to fall through from evident prior toilet backups soaking into it.

So I dug out the side of the building and repaired the floor and replaced the (crappy) toilet (pun intended).

Anyway... after taking a break I went back out to find a pair of eyes peeping out at me from under the house. A pup. It took me about an hour and a half to coax her out to eat a little food and drink some water, and another thirty minutes or so to be able to pick her up and take her inside.

After that she decided she was our dog.

(In NM, people will take unwanted dogs out to unpopulated/less-populated areas like where I lived, right on the edge of the res, and dump them there to scrounge and die. I haven’t many kind thoughts for such people.)

Thus is the story of Pumpkin.

If you want to hear the story of Blueberry, please deposit $0.02.

That dog was destined for you, clearly.

A dog requires a lot more attention than I can provide. I don't have an area where walkies are possible, and with my disabilities I don't have the stamina for what's required if I did have the space.

A cat needs a lap, I can provide that until I have to move.

A litter box, I live in an area where going outside is impractical and dangerous. Right next to a heavily trafficked major thoroughfare road and a lot of neighborhood felines that have already staked out their territories.

And food, lots of expensive vet prescribed food.

I grew up having a handful of cats and a dog from time to time.

About that "life story....." You asked about VS. Well, as you can tell the whys and wherefores of my development preferences are part and parcel of my alleged life and history of hardware. :Þ


Before Pumpkin came to us there was Blueberry. Our neighbors had a surprising number of dogs (which we eventually learned was because people would show up and dump their dogs on them). They were going to be out of town for a couple of weeks, so besides asking us to keep an eye on their house while they were gone, they also asked us to house their two smallest dogs for the duration. Rationale: whenever they left somewhere one of the small dogs died (usually by coyote).

The smallest were a white Chihuahua, and a little black terrier (actually mostly Chihuahua too, lol) named Blueberry.

So, we had Snow and Blueberry as house guests for two weeks. And I had been surprised by how much I kind of enjoyed having them around. (I generally have no interest in keeping pets, but animals seem to like me.)

Afterwards, after the neighbors had returned, I joked to my wife that I was going to kidnap Blueberry for a few days. She laughed and repeated the joke to the neighbor.

To which the neighbor replied, She’s yours, then. (If you want her.)

Blueberry was just another one of the dogs people had dropped off on them, and she had no real interest in her.

So... we had a dog.

BTW, Chihuahuas are barky little barkers.
Last edited on
That's another reason why a dog wouldn't be a good match for me, I'd require a small pooch and yes, as you point out, they ain't quiet.

As noisy as my cat can get when he wants to be fed, when startled or annoyed he just slinks off to one of his safe spots.
Once upon a time I got a task to build a program in Windows. It had been written on SGI IRIX, with Qt. Obviously, Windows did not have GCC and Make by default. No trivial way to simply tmake && make. One of the things that I did try was installation of VS -- just to get a C++ compiler. I did start that "IDE". It had bells. It had whistles. "What a load of useless crap" I thought, exited that for good and found a more familiar way to actually get the job done. Might have been cygwin. MSYS came a bit later?

How one builds a project or how a dog barks are not the most typical "C++ Questions" (although the latter does show up in polymorphism).
struct Giraffe : public Animal
  void bark() override
    std::cout << "what? wait, no, I think you've got the wrong animal, man. it wasn't me...\n";

Student polymorphism problems are real.

Pass the meow()
how to build is just not taught well in most schools. you are expected to just figure it out, and the unix way is not trivial. cmake has taken a lot of the really weird stuff from original make away, but its still rather convoluted.

borland etc way back when had a command line make that was pretty similar to unix. I thought MS did too, but I really don't remember: no one used that stuff because project/IDE build was so much easier. It felt like it was just there to get unix stuff to build, but that almost never worked...
MS has make as well. It doesn’t behave exactly like GNU make, though, and there is plenty online about dealing with the differences between the two when crafting makefiles — you just have to find the magic search terms.

I will often make a “solution” that msbuild can use to compile a project with MSVC. Works on the command line and inside the VS IDE. (’Cause it’s the same thing, methinks.)

I tend to ignore make these days, and CMake has ticked me off because I hit its idiosyncrasies too often and am just not interested in learning its deep dark weirdnesses. So I’ll craft something simple using Tcl. Does all the same stuff as Make, just as readable, whole lot more flexible.

Of course that means user has to have Tcl installed on their system, which once-upon-a-time wasn’t an issue, but apparently for ten years or so now some Linuxes have been pushed that do not have Tcl installed automatically, making an apt-get install tcl (or equivalent) necessary. Foo.
I thought MS did too, but I really don't remember: no one used that stuff because project/IDE build was so much easier.

VS has the cl command to compile and link. If you use VS project properties/Configuration Properties/c++/command line and project properties/Configuration Properties/linker/command line you can see the cl options used for the properties that have been set.
how to build is just not taught well in most schools.

Learning how to do command-line builds with VS or another IDE like Code::Blocks isn't something easily found for a self-taught programming hobbyist like myself either.

I know it can be done, it just takes time and effort. Intellectually I know I should learn, it is on my to-do list, I just am not all that motivated to do it at present.

I probably should just go whole hog, install MSYS2 and make the time. I ain't gettin' any younger.
One of the biggest stumbling blocks to doing command-line builds, at least for me, is what to do when compiling code that deals with modules. The VS IDE makes it easy to flag a code file as being an interface or internal partition file via a dialog.

Now I see how to do the same with command-line switches.


No follow-up with parts 2 and 3 that I can find. :(

C++23 is somewhat covered for command-line compiling using stdlib modules.

Last edited on
If you create a normal VS solution, then you can compile it on the command-line with msbuild.

The only trick is that you need to initialize the command-line properly, and the MSVC installer puts a couple of items in your Start menu to do just that, so...

You basically already know everything you need.

The tricky stuff comes when making stuff other people can compile, since you have to be careful about how external libraries are referenced in the solution.
If you create a normal VS solution, then you can compile it on the command-line with msbuild.

I am aware intellectually that it is doable. I tried that method several times in the past. To varying degrees of success. Before C++20 was officially adopted. The frustration I was experiencing made me less inclined to do (and learn) the basics of command-line compiling at the time.

If I start back up using command-line compilation again I'd prefer to know/learn how to avoid using the IDE altogether in the beginning. Yeah, I'm hard-headed that way.

When GCC finally catches up with VS in supporting modules knowing how do it via command-line switches will be easier to deal with. Likely not the exact same procedure, but similar enough to make consuming modules less of a PITA outside an IDE.
If you create a normal VS solution

I don't know how to do that. It must be well over 15 years since I've had MSVS in any Windows machine. (Back then the MS implementation of make was called 'nmake'.)
To be fair, I don't know how to create a "solution" with GNU Build System either.

A "project" is presumably a platfrom agnostic description of what should be build. That includes what is obligatory (example: "This program requires XZ Utils.") and optional (example: "If system has XZ Utils, then build binary that uses XZ.") dependencies. Then appropriate tool ('configure', 'qmake', 'cmake', etc) can generate platform specific instructions (e.g. the 'Makefile') that 'make' (or whatever) uses to call some compiler and linker (that the system has) in order to produce the executable/library binaries and whatnot.

Typical source package that has GNU Build System "project" can be then:
./configure (with some options)
make install (although this would usually by default copy to location where regular account cannot copy to, which I prefer not to do)

The CMake is a more recent alternative for the 'configure' (and whatever preceeds that).
Last edited on
It is still called nmake.

A “solution” is MS’s name for a project. Recent versions of VS create .proj files (instead of the older .sln files). MSBuild works on both.

It really is literally the underlying system VS uses to compile your stuff. So if you can put together a project that compiles in VS then you can compile it at the command-line with MSBuild.

A solution is default named the same as the initial project when creating a new project. I usually change that so the solution is named differently from the project. If I add new projects to the solution I need to only enter the new project name and the new project is added to the solution tree.

My up-to-date VS 2022 still creates .sln files at the root, with sub-dirs for each project in the solution.

I want to create several and separate versions of a game I call "BigWhizBang". When creating the initial project I might enter "Version 1" for the project and "BigWhizBang" for the solution. VS creates a root dir named "BigWhizBang" containing:

1. a .sln file named "BigWhizBang.sln"

2. a directory named "Version 1" containing all the code files and several files VS creates to contain various settings for the project. I normally see three VS settings files created.

3. a hidden directory named ".vs" more files for the status and settings of all the projects in the solution.

In the main solution directly there are bin directories created that hold the compiled files. .exe, .dll or whatever type of project being compiled.

You don't have to create separate solution/project directories, there is a check mark for that when creating a new solution. There are still sub-dirs created.

It sounds more complicated than it really is when you can look through the files/folders created.

When creating a new solution I choose to use the Windows Desktop Wizard that lets me choose the type of project. Console app, Desktop (WinAPI) app, DLL or static lib. Selecting empty project and deselecting precompiled headers if checked. A couple of simple steps and VS has a lot of the grunt work done for making a lot of the default settings for each type of project.

Normally I create an empty project so any code files I add them as needed. Using the wizards to default create an app tends to add a lot of IMO unnecessary files.
I always start with empty project files too... nothing VS puts in there by default is ever useful to me.
Pages: 1... 910111213