EEVblog Electronics Community Forum

Products => Computers => Programming => Topic started by: Simon on December 24, 2021, 11:41:26 am

Title: General IDE to learn C++ on
Post by: Simon on December 24, 2021, 11:41:26 am
I have "the book" "Programming principles and practice using C++" by Bjarne Stroustrup. It has example and exercises and he recommends visual studio but this was in 2005. Visusual studio or whatever it is called now it rather bloated for running a few lines of code. Anything else worth using?
Title: Re: General IDE to learn C++ on
Post by: djsb on December 24, 2021, 12:14:59 pm
I have that book also. Still got to start reading it though. You could try Notepad++

https://www.youtube.com/watch?v=GyTBk9QHIgY (https://www.youtube.com/watch?v=GyTBk9QHIgY)

I have also tried WxDevC++ and Code Blocks. I started learning C by using LCC-WIN32 and have also tried PellesC as well.

Good luck.
Title: Re: General IDE to learn C++ on
Post by: Simon on December 24, 2021, 12:21:13 pm
So does notepad++ handle calling the compiler etc or is it just an advanced text editor.
Title: Re: General IDE to learn C++ on
Post by: Lindley on December 24, 2021, 12:31:57 pm
You cannot get much simpler than the free Arduino IDE .

Are you intending to use the Arduino chips/boards or some other micros ?
Title: Re: General IDE to learn C++ on
Post by: djsb on December 24, 2021, 12:37:55 pm
Notepad++ is an advanced text editor. It uses a plugin (NCCEXEC) that runs a script. The script invokes G++ (for c++ programs) using the system command terminal. You have to make sure you install the compiler first (explained in another video above)and make sure it can be run from a command prompt. It's all explained in the video I linked to.
Title: Re: General IDE to learn C++ on
Post by: RoGeorge on December 24, 2021, 12:42:24 pm
AFAIK Notepad++ is not an IDE.

For learning, I think everybody should start with just command line and the simplest possible editor.  No automation, no fancy coloring, nothing.  This will help a lot with understanding what a nice C++ IDE does under the hood.

The steps needed to turn a text source into executable binary are crucial to understand and keep in mind while writing code.

Once those steps are well understood, you can switch to something more comfortable than the command line.  The IDE I liked most was Visual Studio from Microsoft.  There is a free and open source version of it, for any OS.  The Linux one is called "VS Code".  One of the best IDE out there, can be used with any programming language.  I'm a hobbyist in terms of software, but many software devs I've seen doing code for a living were often using Visual Studio.

Eclipse is also an IDE I like for its comfort and features, thought many devs are complaining for it being heavy/slower.  Anyway, it's good to get familiar with it, because Eclipse+GCC is often used by various chip manufacturers in their proprietary IDEs for MCU and embedded.
Title: Re: General IDE to learn C++ on
Post by: gamalot on December 24, 2021, 12:58:07 pm
Visual Studio or Visual Studio Code
Title: Re: General IDE to learn C++ on
Post by: Simon on December 24, 2021, 05:39:19 pm
You cannot get much simpler than the free Arduino IDE .

Are you intending to use the Arduino chips/boards or some other micros ?

No I want to follow the example in the book so embedded environments are out. as for simplest - whatever.
Title: Re: General IDE to learn C++ on
Post by: Simon on December 24, 2021, 05:40:09 pm
Visual Studio or Visual Studio Code

Next time read the post!
Title: Re: General IDE to learn C++ on
Post by: SiliconWizard on December 24, 2021, 05:41:25 pm
I think this was kind of answered already in a thread asking for a free C or C++ compiler on Windows.

If the C++ code you want to work on as an exercise is purely command-line stuff, you can use any free or open-source C++ compiler available on Windows. This other thread mentions them (GCC, CLang...).
And if you absolutely insist on using a full-blown "IDE" just to compile small examples, well, to each their own. But I think IDEs were mentioned too. Codeblocks comes to mind, for instance.
https://www.codeblocks.org/downloads/ (https://www.codeblocks.org/downloads/)
Title: Re: General IDE to learn C++ on
Post by: gamalot on December 24, 2021, 06:42:51 pm
Visual Studio or Visual Studio Code

Next time read the post!

ok, Visual Studio Code
Title: Re: General IDE to learn C++ on
Post by: bill_c on December 24, 2021, 06:49:56 pm
Have you tried Geany? https://www.geany.org/ (https://www.geany.org/)
Title: Re: General IDE to learn C++ on
Post by: IanB on December 24, 2021, 07:12:01 pm
Visual Studio or Visual Studio Code

Next time read the post!

I will second Visual Studio Code. But Visual Studio Community Edition is perfectly fine to install, especially if you just pick the C++ option when you install it. It really is one of the best options out there.
Title: Re: General IDE to learn C++ on
Post by: DC1MC on December 24, 2021, 07:27:04 pm
++1 for Code::Blocks
Title: Re: General IDE to learn C++ on
Post by: SiliconWizard on December 24, 2021, 07:27:49 pm
VS may be fine but the OP explicitely stated that he didn't want it. This didn't look very hard to get. :popcorn:
VS community is a HUGE install, even if you selectively disable everything not strictly needed for basic C++ dev (which takes a while and you're not even sure what will be needed or not), because by default it's even more huge. Gigantic.
Title: Re: General IDE to learn C++ on
Post by: Xupicor on December 24, 2021, 08:51:00 pm
Even though you stated your reason for not wanting Visual Studio - it's still the industry standard.

VSCode is slimmed down, open source (well, the source is open under MIT license, but the MS branded executables you get from Microsoft are not, see VSCodium (https://vscodium.com/) for actually MIT-licensed version if you're bothered with that) and multiplatform, I would at the very least keep in mind that there is such a thing, and it's a really good editor/IDE-light. I stress, really good. Also PlatformIO runs on it, if you're planning to get into microcontroller programming in the future.

There's Eclipse (CDT) and NetBeans which are available for free, support many languages (Java foremost) and are not bad at all - though being run on Java they (especially Eclipse, in my experience) tend to sag a bit. Might not be an issue for you if you're running a modern PC with an SDD, though, and it wasn't that bad even with HDD, but with bigger projects SDD does alleviate some issues with an occasional lag.

If you're just starting you probably won't be running big projects anytime soon. Projects that are one file, or just a couple of files big are perfectly manageable using just a fancy editor like Notepad++, Flo's Notepad2 (I use it as a general replacement for MS Notepad, basically replace notepad.exe with it. It's much snappier than many other programmer's editors mentioned here), Atom, Brackets, Sublime (to name a few newer tech editors), heck, use (G)Vim or Emacs if you're familiar with those, they'll do the job perfectly fine and give you that nineties vibe of linux devs as a bonus. ;)

All you need to do is install GCC/MinGW separately, make sure it works in the terminal. You can then just use the terminal to compile your stuff or use solutions built into the editors to do it for you, if they exist.

Make sure to learn how to use 'make (https://www.gnu.org/software/make/)'. It'll come in handy.

Not a fan of Code::Blocks, but it does indeed come bundled with GCC/MinGW (how old of a version though, I don't know) and it is an IDE, not just an editor, so it's also an option.

I'd stay away from Dev C++ IDE, even though it has been quite popular due to some youtube tutorials (and even some books, regrettably... though not all of them bad at all!) being based around it.

Advice:
Either in the terminal when compiling by hand, makefile, or project options/compiler options in your editor/IDE, be sure to add something akin to this in your compilation line: -pedantic -Wall -Wextra -std=XXXX
where XXXX is a standard revision, like so: -std=c++20. Forcing compliance with other (older) versions of the standard is possible as well. More info in the GCC manual (https://gcc.gnu.org/onlinedocs/gcc/Standards.html).
This will enable a lot of useful warnings and disable some GCC specific extensions that you probably have no interest in using at the moment anyway (as they aren't strictly a part of the language). Those errors and warnings will keep you safe(r) and will help to guide your way. Use them to your benefit. Disable them at your own peril.
Maybe add -Wfatal-errors in there to stop compilation after the first error so that you don't have to wade through many lines of error messages which very well might disappear after the cause of the first error is taken care of. (Always start solving problems with the first error reported.)

Opinion:
I agree to an extent that it's good to start with barebones setup and then go on to see what goodies more advanced editors/IDEs bring, but I would say an editor WITH syntax highlighting is the minimum. There's really no need to torture yourself without this very useful feature. I mean maybe for an hour or so to see what people in the middle ages had to go through, but let's be civilized over here. ;)
Title: Re: General IDE to learn C++ on
Post by: nigelwright7557 on December 24, 2021, 10:50:26 pm
Nothing wrong with Visual Studio for C++.
I wrote a 500,000 line C++ program using it.
You can output stuff to message boxes so you can see the results of your code.
The community edition is free too.


Title: Re: General IDE to learn C++ on
Post by: Simon on December 25, 2021, 08:10:16 am
Eventually I'll be doing C++ on embedded. But for the purposes of the book I need to go through the exercises on a PC. Visual studio "whatever" is just the now common microsoft pain in the butt! It wants a windows log in or something that at work won't work, it will want to constantly update, I have several gazillion types of projects I can start - yes my fault for getting ahead of myself - and even when I follow the instructions in the book carefully I get a big fat nothing plus issues that are IDE related. I want to learn to code, not how to drive microsoft's latest mess only for it all to change next week.

Maybe command line compiling is the best option for this sort of thing.

i have downloaded codeblocks. Was trying to remember if it's the mess that MPLABX is based on that is the only program on earth that is obstinate about being made to work on a 4k monitor rather than just doing as it's told like all other programs. But no that is notbeans.
Title: Re: General IDE to learn C++ on
Post by: Gixy on December 25, 2021, 08:17:51 am
VS Code + PlatformIO, nothing more, nothing less. Much more simple than Eclipse.
Title: Re: General IDE to learn C++ on
Post by: IanB on December 25, 2021, 08:26:05 am
Maybe command line compiling is the best option for this sort of thing.

For small code snippets, you might want to look at one of the web compilers. There are various lists of these to give you an idea of what to look at, for example these ones:
https://www.techgeekbuzz.com/best-online-cpp-compiler/ (https://www.techgeekbuzz.com/best-online-cpp-compiler/)
https://arnemertz.github.io/online-compilers/ (https://arnemertz.github.io/online-compilers/)

Compiler Explorer (Godbolt) is a good example, and is fun to use: https://godbolt.org/ (https://godbolt.org/)


Title: Re: General IDE to learn C++ on
Post by: djsb on December 25, 2021, 08:46:57 am
I have just compiled the "hello_world.cpp" example in Chapter 2 of the book using Code:blocks.
I started a new project of type "console application" in the "new from template" dialog and then completed all the entries in the wizard. Make sure you download the std_lib_facilities.h
header file by typing stroustrup com programming std_lib_facilities h in google. Then replace the header file in the main.cpp file of your project with #include "std_lib_facilities.h". You also have to add "std_lib_facilities.h" to your project by right-clicking on the "hello_world" project in the tree to your left and choosing "add files" and then pointing to where this header file is located.
You then click on the green arrow/cog icon (Build and run), and it should compile properly and produce a command window with the "hello world" message and then asks you to press any key to continue.
Title: Re: General IDE to learn C++ on
Post by: RoGeorge on December 25, 2021, 09:32:02 am
https://www.eclipse.org/downloads/packages/ (https://www.eclipse.org/downloads/packages/)

Download, unzip, and run.  No need to install.  There is another page if you want Eclipse with installer.  Another way is to configure your own Eclipse, but that might be tricky for a first time.  However, there are 2 "Eclipse" pre-configured for C/C++, one is for PC dev, the other for embedded dev, you can get them both:

https://www.eclipse.org/downloads/packages/release/2021-12/r/eclipse-ide-cc-developers (https://www.eclipse.org/downloads/packages/release/2021-12/r/eclipse-ide-cc-developers)
https://www.eclipse.org/downloads/packages/release/2021-12/r/eclipse-ide-embedded-cc-developers (https://www.eclipse.org/downloads/packages/release/2021-12/r/eclipse-ide-embedded-cc-developers)
Title: Re: General IDE to learn C++ on
Post by: DC1MC on December 25, 2021, 10:03:52 am
Regarding Code::Blocks, I leave this here, as is not so wide known:
Like many other IDEs, it has it's own project definition file (readable XML, not some (semi)binary rubbish), some times it is necessary to give your project in buildable source and a Makefile will help with the "purists" that do not conceive anything else than Makefiles.

So we have https://github.com/mirai-computing/cbp2make (https://github.com/mirai-computing/cbp2make) that converts the project to a pretty easy to understand Makefile, if a bit too verbose and explicit for the purists that come with the dreadful one-liners for the leet, that are uses to job security and showin off.

 Cheers,
 DC1MC
Title: Re: General IDE to learn C++ on
Post by: Simon on December 25, 2021, 10:09:38 am
Regarding Code::Blocks, I leave this here, as is not so wide known:
Like many other IDEs, it has it's own project definition file (readable XML, not some (semi)binary rubbish), some times it is necessary to give your project in buildable source and a Makefile will help with the "purists" that do not conceive anything else than Makefiles.

So we have https://github.com/mirai-computing/cbp2make (https://github.com/mirai-computing/cbp2make) that converts the project to a pretty easy to understand Makefile, if a bit too verbose and explicit for the purists that come with the dreadful one-liners for the leet, that are uses to job security and showin off.

 Cheers,
 DC1MC

That made no sense to me at all. To restate for those running away with themselves:

1) i have a book
2) it has exercises that need to be compiled and run on a console
3) the IDE recomended does not really exist anymore
4) I need an IDE that will not do silly stuff like the book itself warns of VS of 2005 running the code you just wrote and then closing the console window so that you can't see the result and think you did it wrong despite it being fine.
5) I just need something that works without hours of learning it and how to make it not do it's own thing it thinks is what I want because ultimately I need to run on embedded so getting into the whole how this will compile a program for windowsn is not very relevant right now.
Title: Re: General IDE to learn C++ on
Post by: djsb on December 25, 2021, 10:14:52 am
Did you read my post above?
Title: Re: General IDE to learn C++ on
Post by: DC1MC on December 25, 2021, 10:23:59 am
Regarding Code::Blocks, I leave this here, as is not so wide known:
Like many other IDEs, it has it's own project definition file (readable XML, not some (semi)binary rubbish), some times it is necessary to give your project in buildable source and a Makefile will help with the "purists" that do not conceive anything else than Makefiles.

So we have https://github.com/mirai-computing/cbp2make (https://github.com/mirai-computing/cbp2make) that converts the project to a pretty easy to understand Makefile, if a bit too verbose and explicit for the purists that come with the dreadful one-liners for the leet, that are uses to job security and showin off.

 Cheers,
 DC1MC

That made no sense to me at all. To restate for those running away with themselves:

1) i have a book
2) it has exercises that need to be compiled and run on a console
3) the IDE recomended does not really exist anymore
4) I need an IDE that will not do silly stuff like the book itself warns of VS of 2005 running the code you just wrote and then closing the console window so that you can't see the result and think you did it wrong despite it being fine.
5) I just need something that works without hours of learning it and how to make it not do it's own thing it thinks is what I want because ultimately I need to run on embedded so getting into the whole how this will compile a program for windowsn is not very relevant right now.

Simon, C::B does this by the default install, no need for other plugins or utilities except what is included in the default install, as some other forum member showed practically how to compile the "Hello world" example with C::B on the Windows platform, on Linux is even simpler. So just install it an run it, it takes maybe three minutes to test your examples.

The Makefile generator utility I've mentioned here in case you'll proceed further after the book and maybe share your project or give it to a customer.

I'm willing to drive you trough the hops with C::B and a couple of your book examples via Skype, Zoom, Jisti, whatever, as the weather here in the German industrial town is completely shite (pouring rain, 12C, wtf, is end of December  :scared: ) and I'm blocked in front of the PC anyway.

 Cheers,
 DC1MC
Title: Re: General IDE to learn C++ on
Post by: paf on December 25, 2021, 11:45:02 am
Supposing you usually have a Windows PC, you have several alternatives:

1)  Install WSL2 and Debian or Ubuntu on WSL2 and VS Code or other editor on Windows. You can edit the files from Windows and run them on the WSL terminal.
2)  Install Virtual Box, a Linux  on Virtual Box, and define a shared folder.   You can edit the files from Windows and run them on Linux.
3)  Install Virtual Box, a Linux  on Virtual Box, and define a shared folder for file sharing.  You can edit the files on Linux using an editor/IDE like Geany.
4)  Install Linux on a PC.  You can edit the files on Linux using an editor/IDE like Geany, or any other simple editor.

On Linux/WSL besides using the latest version of gcc or llvm for compiling, when you don't understand what the hell is happening with your C/C++program, you can:

a) Use all the complier warnings
b) Use cppckeck   https://cppcheck.sourceforge.io (https://cppcheck.sourceforge.io) 
c) Use splint      https://splint.org/ (https://splint.org/)   (Only C)
d) Run your program with Valgrind  https://valgrind.org (https://valgrind.org)
e) Debug your program with gdb (which has support for many embedded micros).

All these suggestions are also valid for embedded development.
 
 
 
Title: Re: General IDE to learn C++ on
Post by: hgl on December 25, 2021, 11:58:09 am
Quote
4) I need an IDE that will not do silly stuff like the book itself warns of VS of 2005 running the code you just wrote and then closing the console window so that you can't see the result and think you did it wrong despite it being fine.
Every C / C ++ program begins with calling "main" and ends with exiting main. If you do not want your console to close, simply add a keyboard query to the end of your code and wait for a key to be pressed.

Quote
5) I just need something that works without hours of learning it and how to make it not do it's own thing it thinks is what I want because ultimately I need to run on embedded so getting into the whole how this will compile a program for windowsn is not very relevant right now.



If you want to write embedded code you need a cross-compiler for your target system. Visual C can't do that. Usually GCC is used for this. There is no console in embedded systems without an operating system. Your code runs in an endless loop within main.

An online IDE can be used for the book examples. https://ide.judge0.com/
For embedded code, I would recommend Visual Studio Code with GCC. VSCodium is the same without Mirosoft extensions.
Is faster and easier to use than Eclipse.



Title: Re: General IDE to learn C++ on
Post by: DC1MC on December 25, 2021, 12:11:42 pm
Supposing you usually have a Windows PC, you have several alternatives:

1)  Install WSL2 and Debian or Ubuntu on WSL2 and VS Code or other editor on Windows. You can edit the files from Windows and run them on the WSL terminal.
2)  Install Virtual Box, a Linux  on Virtual Box, and define a shared folder.   You can edit the files from Windows and run them on Linux.
3)  Install Virtual Box, a Linux  on Virtual Box, and define a shared folder for file sharing.  You can edit the files on Linux using an editor/IDE like Geany.
4)  Install Linux on a PC.  You can edit the files on Linux using an editor/IDE like Geany, or any other simple editor.

On Linux/WSL besides using the latest version of gcc or llvm for compiling, when you don't understand what the hell is happening with your C/C++program, you can:

a) Use all the complier warnings
b) Use cppckeck   https://cppcheck.sourceforge.io (https://cppcheck.sourceforge.io) 
c) Use splint      https://splint.org/ (https://splint.org/)   (Only C)
d) Run your program with Valgrind  https://valgrind.org (https://valgrind.org)
e) Debug your program with gdb (which has support for many embedded micros).

All these suggestions are also valid for embedded development.
 

Because all of this complex stuff is so much easier for a beginner than downloading the Code::Blocks installation package with included gcc compilers for Windows: https://www.fosshub.com/Code-Blocks.html?dwl=codeblocks-20.03mingw-setup.exe (https://www.fosshub.com/Code-Blocks.html?dwl=codeblocks-20.03mingw-setup.exe)
then after finishing his book examples go in Linux and get the same package plus whatever cross compilers and just retarget his project with a couple of clicks   :palm:
Title: Re: General IDE to learn C++ on
Post by: JohanH on December 25, 2021, 12:22:23 pm
If you want to learn embedded, learn to use linux command line and gcc. When you understand the basics, you can move to any platform and whatever bloated environment you want.
Title: Re: General IDE to learn C++ on
Post by: djsb on December 25, 2021, 12:31:06 pm
As a beginning programmer all I want to do is to get through the book and actually learn the language, NOT fight the IDE. This is why setting up the development environment is a big hurdle to get over.
Notpad++ and code:blocks works for me and I have the exact same book as Simon has. I've been put off actually reading the book until now as I have come across the same problems with bloated and intimidating IDE software.
Title: Re: General IDE to learn C++ on
Post by: Siwastaja on December 25, 2021, 12:31:48 pm
1) i have a book
2) it has exercises that need to be compiled and run on a console

So you don't need an IDE. All you need is compiler and any text editor of your choice. I use gedit, used to use Notepad++ and Programmer's Notepad far in the past in my Windows days. Many have some helpful programming features like syntax highlighting without all the bloat. Minimize number of tools by not using unnecessary tools. Compiler itself can't be avoided.

You can configure many text editors to run a command on a keypress but I don't bother, with today's multitasking operating systems, why not just have multiple windows open, code editor in one window, command prompt in another.

Either write a makefile or if that sounds too compilated (I accept it is), just m.bat or m.sh, then just run m on the command prompt window and it compiles.

Compiling on g++ for example
g++ -Wall excercise.cc -o excercise[.exe]

You can even just write this and press the arrow up key and enter to compile.

Doesn't need to be made difficult.

With todays large display resolutions (1920 pixels minimum, and sometimes more! wow!), you can easily run the command prompt and the code editor side-by-side so that alt+tabbing doesn't mess up your visual concentration. Compared to this, some IDEs, at least by default, give a tiny output on the bottom of the screen which fits maybe 10 lines.
Title: Re: General IDE to learn C++ on
Post by: DC1MC on December 25, 2021, 12:37:20 pm
If you want to learn embedded, learn to use linux command line and gcc. When you understand the basics, you can move to any platform and whatever bloated environment you want.

Sure, after spending like 30min - 1h learning vi, then spend another hour or such to learn the advanced syntax for Makefiles and its interaction with gcc, also spend 2-3 hours to understood all the advanced gcc switches related to specific architectures, make sure to focus on your installed gcc version as they may produce different effects on each version, then CMake and Ninja meta-generators are a big help and makes your life easier, so spending another hour or two understanding them may help with complex projects, otherwise vi (vim if you want to go on the bloated way) and gdb should be enough for an absolute beginner  :-DD :palm:. All in all a Saturday* well spend for your future professional development.

* = It has to be noted that the hours mentioned above are Saturnian hours and a Saturnian Saturday as well, if done less frequently it may take a Saturnian month  >:D.

This is how all the experts on the forum learned this stuff, and they've now won by hard work and dedication the right to summarily dismiss all of those "bloated IDE" that do all this stuff with a couple of clicks.

NOTE: Code::Blocks is NOT bloated, is one of the most lightweight IDE for the feature it offers.
Title: Re: General IDE to learn C++ on
Post by: Ian.M on December 25, 2021, 12:54:17 pm
The Orwell fork of Bloodshed DevC++ still works, and is a lot lighter than many other IDEs that have been suggested.
https://sourceforge.net/projects/orwelldevcpp/ (https://sourceforge.net/projects/orwelldevcpp/)

However it is a bit fussy to set up to use a recent GCC compiler properly.  Grab TDM-GCC 10.3.0 from: https://jmeubank.github.io/tdm-gcc/ (https://jmeubank.github.io/tdm-gcc/) and install it.  You probably want (and only need) the 64 bit install unless you are using a legacy 32 bit Windows.  Make sure you add the MinGW tools folder to your user (or system) path (https://www.computerhope.com/issues/ch000549.htm) (on my system that's C:\TDM-GCC-64\x86_64-w64-mingw32\bin ), otherwise Dev C++ cant do a 'Clean' or 'Rebuild All' successfully (the default makefile needs rm.exe to be findable on the path).

Next you need to set up the new TDM-GCC 10.3.0 compiler. in Dev C++.  Launch Dev C++ and without opening a project, open the menu 'Tools': 'Compiler Options'.  Use the 'Add a compiler set by folder' button (middle of the five grouped buttons - green +) and give it your TDM-GCC root folder (on my system that's C:\TDM-GCC-64 ).  Rename the new compiler from TDM-GCC 10.3.0 to TDM-GCC 10.3.0 64-bit Release (assuming your on Win x64).  Now add another instance of the same compiler, but this time rename it to TDM-GCC 10.3.0 64-bit Debug and in the tab 'Settings': 'Code Generation', set the 'Optimization level (-Ox)' to 'Debug (g)', in the tab 'Settings': 'Linker', set  'Generate debugging information (-g3)' to 'Yes', and check that 'Strip executable (-s)' is set to 'No'.

For convenience, you may wish to add some utilities to the Dev C++ tools menu (by 'Tools': 'Configure tools...').

I have:

'Explore Project Files' which invokes explorer.exe with parameters <PROJECTPATH>

'Console (in project folder)' which invokes C:\Windows\System32\cmd.exe with working directory <PROJECTPATH>

You should now be able to follow any reputable Dev C++ tutorial, or book using Dev C++ with no IDE or toolchain issues.

Title: Re: General IDE to learn C++ on
Post by: m k on December 25, 2021, 02:49:59 pm
You can configure many text editors to run a command on a keypress but I don't bother, with today's multitasking operating systems, why not just have multiple windows open, code editor in one window, command prompt in another.

+1

I'm usually reading manuals in Adobe Reader same way, just make enough copies.

I've used Borland stuff for quite some time.
Can't open a window with MFC.

Community stuff seems to be timed these days.
May, after all, be a better way
Title: Re: General IDE to learn C++ on
Post by: TheCalligrapher on December 25, 2021, 05:08:55 pm
On Linux/WSL besides using the latest version of gcc or llvm for compiling, when you don't understand what the hell is happening with your C/C++program, you can:

a) Use all the complier warnings

If you are using GCC for learning, the first and foremost thing you can do (in both C and C++) is specify `-pedantic-errors` so that the compiler reports errors as errors. A experienced programmer can usually tell, which of GCC "warnings" is not really a warning but a hard error. A student usually can't. This is where `-pedantic-errors` comes to the rescue.

This is, of course, if you want to learn the actual language, instead of the motley/pidgin dialect implemented by GCC in its default configuration.
Title: Re: General IDE to learn C++ on
Post by: Ed.Kloonk on December 25, 2021, 05:29:51 pm
Quick question.

Does anybody use Kdevelop anymore?
Title: Re: General IDE to learn C++ on
Post by: IanB on December 25, 2021, 05:59:37 pm
That made no sense to me at all. To restate for those running away with themselves:

1) i have a book
2) it has exercises that need to be compiled and run on a console
3) the IDE recomended does not really exist anymore
4) I need an IDE that will not do silly stuff like the book itself warns of VS of 2005 running the code you just wrote and then closing the console window so that you can't see the result and think you did it wrong despite it being fine.
5) I just need something that works without hours of learning it and how to make it not do it's own thing it thinks is what I want because ultimately I need to run on embedded so getting into the whole how this will compile a program for windowsn is not very relevant right now.

Did you read my post about online web consoles like godbolt.org? It will do fine for small book examples. It's what experienced programmers use to test things all the time.
Title: Re: General IDE to learn C++ on
Post by: DC1MC on December 25, 2021, 06:23:52 pm
Quick question.

Does anybody use Kdevelop anymore?

I think that, except for some QT development, it went into the way of Anjuta.
Title: Re: General IDE to learn C++ on
Post by: paf on December 26, 2021, 11:53:05 am
Installing Linux (using WSL2) is easy and fast. When using Linux, if you have a shared folder with WSL2 or Virtual Box, you can use any Windows editor you want/like to edit  the source files,  and user the Linux command line to compile and run the programs.

Even when using Linux you are not forced to use vi(m) or emacs to edit the source code. Other beginner friendly "terminal" editors available are nano, pico, joe, micro, ash and jed.
In graphical mode you have Notepad++, Geany, Kate, Atom, Sublime Text or Visual Studio Code.       

Another fast and easy way (but somewhat limited) way of having a Linux command line machine that allows compiling C++ code is grabbing an Android device and installing Termux on it:
https://termux.com  (https://termux.com)

Another suggestion about embedded C++ is going to YouTube, search for "Dan Saks" and watch his videos.
Title: Re: General IDE to learn C++ on
Post by: Simon on December 26, 2021, 02:46:20 pm
That made no sense to me at all. To restate for those running away with themselves:

1) i have a book
2) it has exercises that need to be compiled and run on a console
3) the IDE recomended does not really exist anymore
4) I need an IDE that will not do silly stuff like the book itself warns of VS of 2005 running the code you just wrote and then closing the console window so that you can't see the result and think you did it wrong despite it being fine.
5) I just need something that works without hours of learning it and how to make it not do it's own thing it thinks is what I want because ultimately I need to run on embedded so getting into the whole how this will compile a program for windowsn is not very relevant right now.

Did you read my post about online web consoles like godbolt.org? It will do fine for small book examples. It's what experienced programmers use to test things all the time.

Yes, that is also a way of doing it.
Title: Re: General IDE to learn C++ on
Post by: DrG on December 26, 2021, 03:43:19 pm
I don't know C++ either and, on occasion, consider learning/doing more in that arena. When I have dabbled, I use some form of VS. I have the newer 'community' version as well as some 2012 or so (too lazy to look). The position that they are bloated and a pain is justifiable.

So, I thought about your general example, "I got this book and they say to use____". In this case I was looking at https://www.amazon.com/Hours-Sams-Teach-Yourself-6th/dp/0672337460 (https://www.amazon.com/Hours-Sams-Teach-Yourself-6th/dp/0672337460) to see what they recommended and they said:

MinGW-w64 https://sourceforge.net/projects/mingw-w64/ (https://sourceforge.net/projects/mingw-w64/) Which looks interesting and I don't think it has been mentioned in this thread.

https://www.mingw-w64.org/ (https://www.mingw-w64.org/)

They also mentioned VS varieties which has already been discussed.
Title: Re: General IDE to learn C++ on
Post by: djsb on December 26, 2021, 04:05:57 pm
You can download Code:Blocks with the MinGW compiler included (which means it is installed alongside C:B) or opt to download C:B without the compiler if you already have one installed or want to install it separately.

https://www.codeblocks.org/downloads/binaries/ (https://www.codeblocks.org/downloads/binaries/)
Title: Re: General IDE to learn C++ on
Post by: ejeffrey on December 28, 2021, 03:12:37 am
You are simply not going to find anything reasonably called an IDE that isn't "bloated"

You can use your favorite advanced text editor plus manage your own tool installation, setup and build system or you can get a bloated IDE.  Those are your options.

Mostly the only games in town for IDEs are visual studio, eclipse, and jetbrains each of which come in several variants. They are all huge but they will all do what you need (and much more)

Or you could install Linux or WSL and use g++ from the terminal. That's a good thing to learn anyway.
Title: Re: General IDE to learn C++ on
Post by: Simon on December 28, 2021, 01:16:14 pm
My point was that the book recommended visual studio based on what it was in 2005, I am fairly sure that it is a bit different now in 2021. I never did get the exercise to work.
Title: Re: General IDE to learn C++ on
Post by: nctnico on December 28, 2021, 01:55:47 pm
I have "the book" "Programming principles and practice using C++" by Bjarne Stroustrup. It has example and exercises and he recommends visual studio but this was in 2005. Visusual studio or whatever it is called now it rather bloated for running a few lines of code. Anything else worth using?
No. If you want to get serious about programming in C/C++ you will want to learn how to use a proper IDE. Eclipse CDT comes with a lot of useful features out of the box (like realtime syntax checking, outlines, function cross references, etc, etc). Visual Studio Code is also a good option but you will have to add a whole bunch of plugins to get it to the comfort level of Eclipse CDT.

Going the text-editor / command line route will only lead to more frustration. Going through pages of warnings trying to find the error message that prevents your program from compiling. OR missing that important warning about a bad type conversion.

If you want to venture further down the software development path: I can highly recommend to learn how to use Git. It makes life a lot easier because it allows to you to go back to previous versions (if you cared to commit them) and thus making experimenting with bits of code much easier.
Title: Re: General IDE to learn C++ on
Post by: Simon on December 28, 2021, 02:06:48 pm
At the moment I just need to follow the exercises in the book. My first use will be in microchip studio for embedded stuff. Anything else will come later.
Title: Re: General IDE to learn C++ on
Post by: nctnico on December 28, 2021, 05:23:25 pm
But how are you going to test your code? Step through it line by line with a debugger for example to see what is happening with the variable values. That is much easier to do on a PC based IDE than on a microcontroller. Likely Eclipse CDT and Visual Studio code offer a way easier to use workflow compare to Microchip's own IDE. Last time I had to program for a PIC processor I used Eclipse CDT instead of Microchip's own environment.
Title: Re: General IDE to learn C++ on
Post by: Ed.Kloonk on December 28, 2021, 05:32:09 pm
But how are you going to test your code? Step through it line by line with a debugger for example to see what is happening with the variable values. That is much easier to do on a PC based IDE than on a microcontroller. Likely Eclipse CDT and Visual Studio code offer a way easier to use workflow compare to Microchip's own IDE. Last time I had to program for a PIC processor I used Eclipse CDT instead of Microchip's own environment.

As an aside, this youtuber shows how to do it with VS.

https://www.youtube.com/watch?v=b1VkJODi_4w (https://www.youtube.com/watch?v=b1VkJODi_4w)
Title: Re: General IDE to learn C++ on
Post by: rstofer on December 28, 2021, 05:58:38 pm
Once those steps are well understood, you can switch to something more comfortable than the command line.  The IDE I liked most was Visual Studio from Microsoft.  There is a free and open source version of it, for any OS.  The Linux one is called "VS Code".  One of the best IDE out there, can be used with any programming language.

Except...  It won't print your files!  To me, this seems like a really HUGE failing.  Nevertheless, I use it for Python and VHDL and when I want a listing, I use Notepad++.

I would just get used to Visual Studio Community Edition (free) on Windows.  For Linux, I would probably just use GCC from the command line.  I run gfortran from Eclipse so I'm into most of the high end IDEs.
Title: Re: General IDE to learn C++ on
Post by: SiliconWizard on December 28, 2021, 07:04:04 pm
Once those steps are well understood, you can switch to something more comfortable than the command line.  The IDE I liked most was Visual Studio from Microsoft.  There is a free and open source version of it, for any OS.  The Linux one is called "VS Code".  One of the best IDE out there, can be used with any programming language.

Except...  It won't print your files!  To me, this seems like a really HUGE failing.  Nevertheless, I use it for Python and VHDL and when I want a listing, I use Notepad++.

I would just get used to Visual Studio Community Edition (free) on Windows.  For Linux, I would probably just use GCC from the command line.  I run gfortran from Eclipse so I'm into most of the high end IDEs.

There are tons of options on Windows as well, as we mentioned. You can use command-line GCC or Clang either on MSYS2, or even directly in a Windows console. You can also use Codeblocks, which integrates all this nicely, so easier for people not comfortable with the command line. Or another IDE of your liking, and set it up for your compiler. If you like Notepad++, so be it. There is Geany also, which is rather nice, and has printing (and is cross-platform, while not being Java!). There's also Vim, for those who are into that, or Emacs, or Atom, or a bunch of others..

There definitely are a lot of options beyond MS tools. Some people here make it sound like there isn't, and frankly some even almost sound like MS salespersons. :-DD
Title: Re: General IDE to learn C++ on
Post by: ejeffrey on December 28, 2021, 07:30:49 pm
My point was that the book recommended visual studio based on what it was in 2005, I am fairly sure that it is a bit different now in 2021. I never did get the exercise to work.

And everyone here is telling you it's still a good recommendation in 2021.  There are other options as well.  Just pick something and use it. Literally anything you pick will work for your needs.  Don't worry about "bloat." You will have to learn how the tool works but you should be able to get any tool you pick running in an afternoon.
Title: Re: General IDE to learn C++ on
Post by: Ian.M on December 28, 2021, 08:08:28 pm
My point was that the book recommended visual studio based on what it was in 2005, I am fairly sure that it is a bit different now in 2021. I never did get the exercise to work.
At the moment I just need to follow the exercises in the book. My first use will be in microchip studio for embedded stuff. Anything else will come later.

As I said earlier, Dev-C++ is still usable under Win 10, and can be upgraded to a reasonably current GCC version.   It took me about five minutes to create a Win32 Console project and enter the "hello_world.cpp" example from chapter two of your book, and as soon as I realized that the header "std_lib_facilities.h" is custom for the book and needs to be downloaded from Stroustrup's site (https://www.stroustrup.com/Programming/std_lib_facilities.h), I added it to the project, and it then compiled with no errors or warnings and ran successfully and correctly.   

I detailed what's needed to get Dev-C++ up and running under Win 10 back in reply #34 (https://www.eevblog.com/forum/programming/general-ide-to-learn-c-on/msg3895238/#msg3895238) and attach the minimum set of project files for Dev-C++ for the chapter two hello world program.  Just unzip them in a new folder, open the '.dev' (project) file and build and run.
Title: Re: General IDE to learn C++ on
Post by: SiliconWizard on December 28, 2021, 08:27:56 pm
Ah yes, I forgot about Dev-C++ (I thought it was dead, actually, but apparently, Embarcadero now "hosts" the project. But it's open-source and available there: https://github.com/Embarcadero/Dev-Cpp )
So, that's indeed yet another option.
Title: Re: General IDE to learn C++ on
Post by: IanB on December 28, 2021, 09:51:04 pm
Also, see this page: https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170

Quote
You can build C and C++ applications on the command line by using tools that are included in Visual Studio. The Microsoft C++ (MSVC) compiler toolset is also downloadable as a standalone package. You don't need to install the Visual Studio IDE if you don't plan to use it.

So, if you are really opposed to using an IDE, you can download and use the Microsoft compilers without needing to install Visual Studio.

Honestly, I do understand the annoyance of making a new project in an IDE just to run a few lines of code. The way I approach this is to make a "learning project", and then for each small example I want to test I just make a function in my project containing those few lines of code. It's pretty easy to have the main program call whichever test function I want to run.
Title: Re: General IDE to learn C++ on
Post by: Simon on December 28, 2021, 10:52:20 pm
But how are you going to test your code? Step through it line by line with a debugger for example to see what is happening with the variable values. That is much easier to do on a PC based IDE than on a microcontroller. Likely Eclipse CDT and Visual Studio code offer a way easier to use workflow compare to Microchip's own IDE. Last time I had to program for a PIC processor I used Eclipse CDT instead of Microchip's own environment.

FFS read!

Lets start again for the hard of hearing (and intellect!):

while my ultimate aim is to program on a micro-controller I am following (or will when I get the time to set this up) a book with examples to use on a PC. The book recommends VS but does point out that this is 2005 (the guy had vision and knew that the book would be read years later when the IDE would be totally different and a mess). So if I try to follow the setup described notthing happens. So clearly as the author anticipated the IDE in 2005 has now changed to the point that it's more work to get the IDE to work than do the example.

Therefore I am looking for an IDE that is as simple to use as VS was in 2005 to carry out the examples as intended on a PC!

Once I have got to grips with the language yes my target will be embedded, for now I want a hassle free IDE that lets me test the code as I need at least one first little test program to work before I can figure if it's me or the IDE.
Title: Re: General IDE to learn C++ on
Post by: Simon on December 28, 2021, 10:55:48 pm
My point was that the book recommended visual studio based on what it was in 2005, I am fairly sure that it is a bit different now in 2021. I never did get the exercise to work.

And everyone here is telling you it's still a good recommendation in 2021.  There are other options as well.  Just pick something and use it. Literally anything you pick will work for your needs.  Don't worry about "bloat." You will have to learn how the tool works but you should be able to get any tool you pick running in an afternoon.

NO IT WON'T AS IT HAS NOT!.  Clearly VS in 2021 is more complex than in 2005, I tried it and nothing happened! clearly too much going on, I need something that won't try to be too clever and just do what ID need it to, ever heard of MS writing software like that in the last decade? no me neither! I also want to use it at work and if I have to update something or log back in every 5 seconds I will drive the IT contractor up the flaming wall!
Title: Re: General IDE to learn C++ on
Post by: IanB on December 28, 2021, 11:28:53 pm
Simon, you seem to be getting very agitated, but it is hard to figure out where the difficulty lies among three things:

1) Installing (just) the C++ desktop workload for Visual Studio Community
2) Getting code samples from the book to run
3) Following instructions in the book for installing Visual Studio

From your comments, it seems like you might be getting stuck on (3), but if so, do not even think about following those instructions. They will be 15 years out of date, and no longer applicable.

For item (1), if you were to go this way, you would just pick the "Desktop Development with C++" workload (see screenshot below), and nothing else. I am probably going to do this on my computer in a minute just to verify.

For item (2), this should be quite straightforward, once you have a compiler installed.

However, there is a caveat that nobody has mentioned in this thread so far. The C++ language today has evolved far beyond where it was in 2005. In 2005 we had "traditional C++" as Bjarne Stroustrup originally conceived it. Today, we have "modern C++", which has a much better, safer, and more reliable way of programming (which Bjarne Stroustrup strongly recommends).

So if you are going to learn C++, it would be best to use a modern reference, and try to use language standard C++17 or later.

The only counter to this, is for embedded programming, where vendor toolchains may not support all the features.

However: learning how to program includes learning how to obtain, install, and use development tools. You need to consider this as part of your learning exercise, and not just focus on the code examples.
Title: Re: General IDE to learn C++ on
Post by: IanB on December 28, 2021, 11:38:31 pm
Here it goes:
Title: Re: General IDE to learn C++ on
Post by: IanB on December 28, 2021, 11:50:03 pm
And it's done, installed and working:
Title: Re: General IDE to learn C++ on
Post by: Tony_G on December 29, 2021, 12:25:30 am
I think that Ian's post is pretty good start on the process of installing.

That said, Simon, I worked on the VS team for 17 years, and seeing how you're frustrated at using VS and the work you do for the forum as a moderator, I'd be more than happy to spend some time in a Zoom meeting with you to get you going in VS2021 Community Edition.

Just PM me if you'd like to give this a try.

TonyG
Title: Re: General IDE to learn C++ on
Post by: DrG on December 29, 2021, 03:53:02 am
I was looking at the book today. There are some other potential concerns with using a modern compiler/linker/IDE/OS with some of those code examples and exercises.

As was mentioned earlier, there is a common header file that needs to be used www.stroustrup.com/Programming/std_lib_facilities.h (http://www.stroustrup.com/Programming/std_lib_facilities.h) and that certainly is available, but could cause some issues. Maybe not though as you can see this comment "Revised August 3, 2020: a cleanup removing support for ancient compilers".

The graphics/GUI exercises and code use a tool library FLTK https://www.fltk.org/ (https://www.fltk.org/) In the book, they use "FLTK 1.1.x" and  I see you can still download 1.1.10, but I wonder if VSC22 will barf at the thought. More importantly, I wonder if modernish Windows will barf. Anybody have some thoughts on that?

I don't know, but I do know who the author is and I understand why you would want to start to learn C++ from him, but there are more modern texts available - no?
Title: Re: General IDE to learn C++ on
Post by: Siwastaja on December 29, 2021, 11:57:21 am
I can feel the frustration.

Do this:
Install mingw
Write hello world example.
Compile by:
g++ test.cc -o test.exe
Run:
test.exe

Take small steps. Go from there.

And despite what nctnico says, you don't absolutely need a full-fledged IDE. You might want it, you might not, it's also a personality question. I have no issue whatsoever working with a text editor and command line, but I do many other things completely opposite how nctnico claims they "must" be done, as well. I don't get frustrated at large number of errors and warnings because I don't usually write massive pieces of untested code at once. When I do, then I just work through the errors and warnings one by one, but this doesn't happen often.

But yeah, C++ has a tendency of generating 100 screenfuls of cryptic error messages on a slightest typo. I kinda understand the appeal to helper tools with such horrible language. You can still start without. I actually started with C++ as my first programming language - it was very new and trendy back then - and definitely did not have any IDE; not even alt+tab because was in MS-DOS, so it was save - exit - compile - start editor again process. That sucked, yes, but got the job done anyway.
Title: Re: General IDE to learn C++ on
Post by: Simon on December 29, 2021, 12:02:04 pm
The book is relatively recent but was first written a while ago so some of the text is old. This is why I suspect he noted the 2005 against the recommendation for VS. As there is now more to VS than then trying to follow setting up the IDE is not possible. I thought I had picked a console project and I don't think the option to keep the console open was there so it made the whole thing futile. My code may have run perfectly but I just never got to see it.

This is why I was thinking something a little simpler.
Title: Re: General IDE to learn C++ on
Post by: Simon on December 29, 2021, 12:04:44 pm

And despite what nctnico says, you don't absolutely need a full-fledged IDE. You might want it, you might not, it's also a personality question.

I do like to use colour as a way of differentiating things. I find reading block capitals hard so I prefer the colour coding of defines rather than writing them in block capitals
Title: Re: General IDE to learn C++ on
Post by: emece67 on December 29, 2021, 01:52:37 pm
.
Title: Re: General IDE to learn C++ on
Post by: DrG on December 29, 2021, 02:29:08 pm
I thought I had picked a console project and I don't think the option to keep the console open was there so it made the whole thing futile. My code may have run perfectly but I just never got to see it.

This is why I was thinking something a little simpler.

That is normal Windows console window programming working.

If debug mode, I make sure this is unchecked (VS19) [Tools->Options->Debugging->Automatically close the console]

(https://www.eevblog.com/forum/programming/general-ide-to-learn-c-on/?action=dlattach;attach=1363301;image)

But, this situation is well known and VS has advanced beyond having to use getchar() in the code to make blocking loops to keep the window open.

See here https://stackoverflow.com/questions/1775865/preventing-console-window-from-closing-on-visual-studio-c-c-console-applicatio (https://stackoverflow.com/questions/1775865/preventing-console-window-from-closing-on-visual-studio-c-c-console-applicatio) [and a bunch of other places]


Title: Re: General IDE to learn C++ on
Post by: Siwastaja on December 29, 2021, 02:59:27 pm
I do like to use colour as a way of differentiating things. I find reading block capitals hard so I prefer the colour coding of defines rather than writing them in block capitals

I also do use a text editor (gedit) which comes with decent syntax highligting. It's advanced enough to understand that #if 0 #endif is a comment, and color the text accordingly.

Between a massive bloat IDE and vi, there are many options.

In Windows, I'm pretty sure Notepad++ hits the sweet spot of being more than just primitive text editor, without being a full fledged IDE. But it's over a decade I last used it.
Title: Re: General IDE to learn C++ on
Post by: nctnico on December 29, 2021, 03:34:44 pm
But how are you going to test your code? Step through it line by line with a debugger for example to see what is happening with the variable values. That is much easier to do on a PC based IDE than on a microcontroller. Likely Eclipse CDT and Visual Studio code offer a way easier to use workflow compare to Microchip's own IDE. Last time I had to program for a PIC processor I used Eclipse CDT instead of Microchip's own environment.

FFS read!

Lets start again for the hard of hearing (and intellect!):

while my ultimate aim is to program on a micro-controller I am following (or will when I get the time to set this up) a book with examples to use on a PC. The book recommends VS but does point out that this is 2005 (the guy had vision and knew that the book would be read years later when the IDE would be totally different and a mess). So if I try to follow the setup described notthing happens. So clearly as the author anticipated the IDE in 2005 has now changed to the point that it's more work to get the IDE to work than do the example.

Therefore I am looking for an IDE that is as simple to use as VS was in 2005 to carry out the examples as intended on a PC!

Once I have got to grips with the language yes my target will be embedded, for now I want a hassle free IDE that lets me test the code as I need at least one first little test program to work before I can figure if it's me or the IDE.
Don't try to run before you can walk. Also don't expect a book from 15 years ago to be accurate. The C++ standard has changed in the meantime as well so some examples in the book could use constructs that throw an error instead of a warning.

To get going with Visual Studio Code:
https://code.visualstudio.com/docs/setup/windows (https://code.visualstudio.com/docs/setup/windows)
https://code.visualstudio.com/docs/cpp/introvideos-cpp (https://code.visualstudio.com/docs/cpp/introvideos-cpp)

Found these with a website called Google.
Title: Re: General IDE to learn C++ on
Post by: Siwastaja on December 29, 2021, 03:43:08 pm
Yeah, C++ has really indeed changed.

I learnt it in mid-90's. Then I learned it more in university in mid-2000's and had to use it at work around 2010. It felt like completely different language than what I originally learnt. Now if you look at the 2021 state, it's again completely different language.

It has changed both for worse, and better. Worse in the way that it's even more complex because not much is removed, only added to it. If you want to interact with other programmers, you need to understand a lot of different constructs. But better in the way that the new features can help reduce amount of boilerplate and make the language higher level.

In any case, C++ will be a massive beast for a beginner, and you can't go for arbitrarily minimal subset if you want to "know C++". For personal and practical purposes, you can of course limit to a tiny subset.

Sorry but if your biggest hurdle is that the IDE automatically closes the terminal window unless you check a checkbox in configuration, and this is enough to make you feel like giving up, I'm not sure if C++ is a good language for you. You need the endurance, because struggling is inevitable.

Some really modern examples, written to be as simple and as high level as possible, could be helpful. It's never a good idea to rely on a single book.
Title: Re: General IDE to learn C++ on
Post by: DrG on December 29, 2021, 04:36:13 pm
So, I want to present a different perspective or, at least, a different context with respect to:

Quote
Sorry but if your biggest hurdle is that the IDE automatically closes the terminal window unless you check a checkbox in configuration, and this is enough to make you feel like giving up, I'm not sure if C++ is a good language for you. You need the endurance, because struggling is inevitable.

Please understand, that I harbor no hard feelings toward you (@Siwastaja) and, to the degree that I can remember, your reputation here is fine.

Nevertheless, what you say there is a bit on the “putting on airs” side. When someone starts on a road, you really do not know where they will end up and it could be in a place that is much “higher” than the place you are at – you just don’t know – even when you know, you don’t know (see reference to the movie “Let it Ride”).

I entered this thread because I am at a place with C++ not unlike the OP’s place. I don’t know C++. While I have “used” it sparingly, I don’t feel like I really know it at all, but learning it is on a very long “to-do” list. My last encounter with learning it shows here https://www.eevblog.com/forum/programming/scaling-brightness-using-pwm/msg3542942/#msg3542942 (https://www.eevblog.com/forum/programming/scaling-brightness-using-pwm/msg3542942/#msg3542942) Translating some messy Arduino code/crap to a little better organized and systematic program was a good candidate for a little C++ learning.

I had the SAME issue and that was in March of this year. WTF?!! How am I going to rewrite the code when the &^@#$%ing window closes on me?! FFS, I am going backwards, not forwards, and I do have other things to do, so FTS!  Which person in this thread has not had similar ideations at some time?

So, yeah, I worked through that, but not because I went through 751,861 options in VS2019, but because I searched until I found some solutions (IOW I asked a friend, or rather eavesdropped on a conversation where someone asked a "friend" – i.e., the internet through Google.

Look at this passage in the very book in question (appendix C):

Quote
C.4 Later
The IDE has an apparent infinity of features and options. Don’t worry about
those early on — or you’ll get completely lost. If you manage to mess up a project
so that it “behaves oddly,” ask an experienced friend for help or build a new project
from scratch. Over time, slowly experiment with new features and options.

OK, maybe he was wrong in the sense that there ARE a few options you need to worry about straightaway, but the OP did ask experienced "friends" and there were plenty of responses, so that is a good thing.
Title: Re: General IDE to learn C++ on
Post by: nctnico on December 29, 2021, 04:55:49 pm
I had the SAME issue and that was in March of this year. WTF?!! How am I going to rewrite the code when the &^@#$%ing window closes on me?! FFS, I am going backwards, not forwards, and I do have other things to do, so FTS!  Which person in this thread has not had similar ideations at some time?
Me certainly. But approaching a problem by throwing tantrums is not going to solve anything. In my experience it is better to take a break (go out for a walk or cycling) and give your brain a rest so it can process & organise the problem.

Nowadays it is super easy to find information on internet on how to achieve something. A couple of years ago I changed to a different PCB layout package. I didn't took a course because I had to get the program going before the first course dates so I used online tutorials and fora to get me going. A couple of hundred hours in I'm pretty good at using the package but I'm still learning. Yesterday I wanted to add some dimensions to a board layout for example. Google found me a video which showed me exactly how to do that.
Title: Re: General IDE to learn C++ on
Post by: alexanderbrevig on December 29, 2021, 05:03:37 pm
You should let us help you with the issue of how to get a modern VS running your code as opposed to finding something akin to VS2005. IDEs are much much better now.

If you decide to hate VS my opinion is you have two choices: CLion and NeoVim.

Good luck!
Title: Re: General IDE to learn C++ on
Post by: PlainName on December 29, 2021, 05:25:37 pm
Here it goes:

Blimey!
Title: Re: General IDE to learn C++ on
Post by: IanB on December 29, 2021, 05:47:42 pm
I thought I had picked a console project and I don't think the option to keep the console open was there so it made the whole thing futile. My code may have run perfectly but I just never got to see it.

Ah, yes, this "feature" has been present in all versions of Visual Studio from the beginning, including the 2005 version. If you do a lot of debugging it does kind of make sense though.

The simplest solution is to use the "Start Without Debugging" option (the button highlighted in the screenshot below). At least this is on the toolbar by default in the latest version of VS -- in earlier versions you had to customize the toolbar to add it, or find it on the Debug menu. You can also use the keyboard shortcut, Ctrl-F5.

Part of learning to program is learning to use the tools, so you should expect to invest some time into this. It's not much different from learning to use an Oscilloscope when doing electronics.
Title: Re: General IDE to learn C++ on
Post by: Ian.M on December 29, 2021, 05:56:09 pm
Orwell Dev-C++ installer 50,433,966 bytes (48 MB)
TDM-GCC 10.3.0 full installer 80,474,875 bytes (76.7 M)
Total  130,908,841 bytes (124.8 MB)

or you could go with the even smaller download of the Embarcadero DEV-C++ fork which includes TDM-GCC 9.2.0, if you trust Embarcadero . . .

Dev-C++ keeps the console open by default:

 Hello, World!

--------------------------------
Process exited after 0.02145 seconds with return value 0
Press any key to continue . . .

Quote from: Dev-C++ Help
Q: Programs created with Dev-C++ show the line "Process exited with return value X". What's going on?
This piece of text is shown when a console program ran via Dev-C++ exits. The host that runs your console program (ConsolePauser.exe) prints this code. Dev-C++ does NOT add any code to your programs to print this. This feature is quite useful because you can see console output before closing. You can remove it by unticking "Tools >> Environment Options >> General >> Pause console programs after return".
Title: Re: General IDE to learn C++ on
Post by: djsb on December 29, 2021, 07:24:54 pm
Just to mix it up a little, I'm giving Visual Studio Community 2022 a go. This is mainly because the book mentioned  earlier uses FLTK for it's GUI examples later on and FLTK comes with ready-made solution files for Visual Studio.
Visual Studio really isn't so scary once you give it a try. I'm going to give the hello_world example a spin and see how I get on.





PS The hello_world example from chapter 2 of the book compiles OK and shows the message in a popup window in VS 2022. I didn't even have to explicitly tell the IDE where to find the header file. It just found it itself.

https://www.youtube.com/watch?v=6sNKtyl4hQM (https://www.youtube.com/watch?v=6sNKtyl4hQM)

https://bumpyroadtocode.com/2017/08/29/how-to-install-and-use-fltk-1-3-4-in-visual-studio-2017-complete-guide-2-0-no-cross-contamination/ (https://bumpyroadtocode.com/2017/08/29/how-to-install-and-use-fltk-1-3-4-in-visual-studio-2017-complete-guide-2-0-no-cross-contamination/)

https://stackoverflow.com/questions/70401545/how-to-use-fltk-graphic-library-with-visual-studio-community-2022-for-c-proj (https://stackoverflow.com/questions/70401545/how-to-use-fltk-graphic-library-with-visual-studio-community-2022-for-c-proj)
Title: Re: General IDE to learn C++ on
Post by: SiliconWizard on December 29, 2021, 07:45:30 pm
Orwell Dev-C++ installer 50,433,966 bytes (48 MB)
TDM-GCC 10.3.0 full installer 80,474,875 bytes (76.7 M)
Total  130,908,841 bytes (124.8 MB)

or you could go with the even smaller download of the Embarcadero DEV-C++ fork which includes TDM-GCC 9.2.0, if you trust Embarcadero . . .

Yeah. OTOH, VS build tools for C and C++ (so only the command-line tools): 2.6 GB. =)
Title: Re: General IDE to learn C++ on
Post by: Siwastaja on December 29, 2021, 08:30:20 pm
I had the SAME issue and that was in March of this year. WTF?!! How am I going to rewrite the code when the &^@#$%ing window closes on me?! FFS, I am going backwards, not forwards, and I do have other things to do, so FTS!  Which person in this thread has not had similar ideations at some time?
Me certainly.

Me too, we all have those moments. It only becomes an issue if you get fixated on the problem so much that just solving it is not enough. This is where people deal with differently. Some will act like this, "oh I see, there was this box to tick, me stupid, d'oh." Others will go, "oh I see, there was this box to tick, what crappy UI design, d'oh". I'm in the latter, but both will work if you just can go on.

But if you decide to give up because of this and go on ranting about it on the Interwebz, you are just wasting your own time; you could be learning C++ instead.

Learning any programming language using any toolset is full of moments like this. If you get stuck for longer than a few hours on them, if they become your painpoints which require lengthy discussions, reaching your actual target is doomed.

Really, most important is just keep the ball rolling. Pick any tool. Heck, even use STM32CubeIDE and Arduino I supposedly so much hate. Use nctnico's favorite, Eclipse, which I also hate, but it's really fine. They are all good enough tools that get the job done.
Title: Re: General IDE to learn C++ on
Post by: nctnico on December 29, 2021, 09:52:10 pm
Actually... if you install GCC for WIndows (Mingw is the best choice IMHO) then STM32CubeIDE will also work for creating programs that run on a PC. After all STM32CubeIDE is just Eclipse with a piece of ST wallpaper stuck onto it.

As a choice of IDE I'd advise to look into Visual Studio code nowadays. I see a lot of programmers around me (with ages from below 20 to over 80) using Visual Studio code. There is also a large ecosystem with plugins for VS code and for some languages (VHDL for example) already more choices than ever existed for Eclipse. It wouldn't surprise me if MCU vendors are switching to it as well in the near future. All in all I have a strong feeling the days of Eclipse are numbered.
Title: Re: General IDE to learn C++ on
Post by: Simon on December 29, 2021, 10:42:52 pm
But how are you going to test your code? Step through it line by line with a debugger for example to see what is happening with the variable values. That is much easier to do on a PC based IDE than on a microcontroller. Likely Eclipse CDT and Visual Studio code offer a way easier to use workflow compare to Microchip's own IDE. Last time I had to program for a PIC processor I used Eclipse CDT instead of Microchip's own environment.

FFS read!

Lets start again for the hard of hearing (and intellect!):

while my ultimate aim is to program on a micro-controller I am following (or will when I get the time to set this up) a book with examples to use on a PC. The book recommends VS but does point out that this is 2005 (the guy had vision and knew that the book would be read years later when the IDE would be totally different and a mess). So if I try to follow the setup described notthing happens. So clearly as the author anticipated the IDE in 2005 has now changed to the point that it's more work to get the IDE to work than do the example.

Therefore I am looking for an IDE that is as simple to use as VS was in 2005 to carry out the examples as intended on a PC!

Once I have got to grips with the language yes my target will be embedded, for now I want a hassle free IDE that lets me test the code as I need at least one first little test program to work before I can figure if it's me or the IDE.
Don't try to run before you can walk. Also don't expect a book from 15 years ago to be accurate. The C++ standard has changed in the meantime as well so some examples in the book could use constructs that throw an error instead of a warning.

To get going with Visual Studio Code:
https://code.visualstudio.com/docs/setup/windows (https://code.visualstudio.com/docs/setup/windows)
https://code.visualstudio.com/docs/cpp/introvideos-cpp (https://code.visualstudio.com/docs/cpp/introvideos-cpp)

Found these with a website called Google.
The book is for C++14 and I think maybe a bit beyond. It is just that it started life in it's first edition earlier and I suspect that is why the comment about 2005 was dropped as they anticipated more editions and that the IDE would change.

How much of the original remains versus new material in the second edition I don't know.
Title: Re: General IDE to learn C++ on
Post by: IanB on December 29, 2021, 11:23:04 pm
I had the SAME issue and that was in March of this year. WTF?!! How am I going to rewrite the code when the &^@#$%ing window closes on me?! FFS, I am going backwards, not forwards, and I do have other things to do, so FTS!  Which person in this thread has not had similar ideations at some time?
Me certainly.

Me too, we all have those moments. It only becomes an issue if you get fixated on the problem so much that just solving it is not enough. This is where people deal with differently. Some will act like this, "oh I see, there was this box to tick, me stupid, d'oh." Others will go, "oh I see, there was this box to tick, what crappy UI design, d'oh". I'm in the latter, but both will work if you just can go on.

This is really a matter of your perspective on the task at hand. Whether you want to run your program, or whether you want to debug it. If you are simply running the program, you do most likely want to see the output in the console window. However, if you are debugging it, it would be a pain to have to keep closing the console window every time you stop debugging.

Both options are present on the Debug menu:

(https://www.eevblog.com/forum/programming/general-ide-to-learn-c-on/?action=dlattach;attach=1363616;image)
Title: Re: General IDE to learn C++ on
Post by: gmb42 on December 29, 2021, 11:58:36 pm
Here it goes:

Blimey!

As noted elsewhere, the size of the actual IDE portion of that download is relatively small, it's all the toolchain bits that make up the majority for x86, x64, all the Windows headers, debuggers, Windows SDK's.
Title: Re: General IDE to learn C++ on
Post by: Vtile on February 06, 2022, 05:25:16 pm
For number 4. One could include a "wait key press" instruction as the last line of the code snippet, if there is no instruction which waits user interaction.

I do not have a word for other numbers as I do try to stay away C(++) toolchain acrobacy. Years ago there was devc++ ide for windows, maybe it is still maintained.

Edit. Didn't notice that there is 4 pages, mobile version of site is not the most informative one.
Title: Re: General IDE to learn C++ on
Post by: rstofer on February 08, 2022, 03:29:52 am
I bought the Fourth Edition of Stroustrup's "The C++ Programming Language" book.  It's a big heavy thing, 1345 pages!

I am going to make one last ditch effort to learn enough of the language to more or less 'like' it.  This isn't my first attempt, I have been trying to like it for 20 years or so.  I just don't see the advantages and that's probably because my projects are small.  I like C, I really prefer Fortran if the application is number crunching and Pascal is my all-time favorite for application programming.

I have an old Dell Inspiron laptop and I just installed Mint Linux with the Cinnamon desktop.  I'll use 'gedit' for the editor (with Alt-Y to shut off syntax coloring) running in one terminal and build/execute the code from a second terminal and the command line.  This is a simple and effective way to develop code on Linux.  I may progress to using Makefiles but they probably aren't necessary for book examples.  I do know how to use 'make' so if it comes up there won't be too many stumbling points.

If I'm going to write command line code, I really prefer to do it on Linux.  Sure, I have Visual Studio and it works fine but it seems a little heavy for snippets of code.  'gedit' is a fine editor when the alternative is 'vi' or 'nano'.  'geany' is another fine editor.  I think Eclipse would be overkill for this evolution but I like the fact it keeps track of projects in a workspace.  It has improved greatly over the years.

If I change my mind and use Win10, I will definitely use Visual Studio.  It creates a project template as a starting point for every project.  Visual Studio works very well and I don't find it terribly unwieldly.

If I install VNC Server on the laptop, I can just let the laptop sit on a shelf in the back room and interact with is using VNC Client from my Win10 workstation (or any other machine).  This works quite well and I do it all the time with Raspian on the Raspberry PI.

Actually, an Intel NUC would be perfect for this application.  Maybe later on...

So many choices...
Title: Re: General IDE to learn C++ on
Post by: DiTBho on February 08, 2022, 03:58:44 am
.. is there anything that doesn't require {GTK2, GTK3, kde}?
anything (open)motif-based?

Yes! despite being a minimalist Motif/X11 plain text editor, NEdit features significant support for programmers including syntax highlighting, macro language, and streamlined keyboard navigation.

I like NEdit combined with auto-tag, this way it automatically generates tags to bookmark functions.
I will integrate Scintilla some day ...

Anyway, it flawlessly works with C, but it's rather clumsy with C++
Title: Re: General IDE to learn C++ on
Post by: ledtester on February 08, 2022, 06:22:19 am
I bought the Fourth Edition of Stroustrup's "The C++ Programming Language" book.  It's a big heavy thing, 1345 pages!

Depending on your goals you might consider starting with Stroustrup's "A Tour of C++".

C++ has a a long history and it's encumbered with a lot of "baggage" so to speak. The the thinking on best practices in C++ has evolved quite a bit over the years. I've heard the leaders of C++ (Bjarne, Herb Sutter, et. al.) express the sentiment that they feel there is a much simpler language that is struggling to express itself within C++.

The CppCon talks on youtube are a good way to keep abreast of how this modern view of C++ is evolving - especially the ones by Bjarne and Herb.
Title: Re: General IDE to learn C++ on
Post by: Simon on February 08, 2022, 07:56:01 am

Depending on your goals you might consider starting with Stroustrup's "A Tour of C++".

C++ has a a long history and it's encumbered with a lot of "baggage" so to speak. The the thinking on best practices in C++ has evolved quite a bit over the years. I've heard the leaders of C++ (Bjarne, Herb Sutter, et. al.) express the sentiment that they feel there is a much simpler language that is struggling to express itself within C++.

The CppCon talks on youtube are a good way to keep abreast of how this modern view of C++ is evolving - especially the ones by Bjarne and Herb.


I have that book too but clearly not a book for a beginner like me as you need a thorough background in programming.
Title: Re: General IDE to learn C++ on
Post by: m98 on February 08, 2022, 01:52:37 pm
I can recommend JetBrains CLion if a commercial IDE is an option. Quite intuitive to learn, works nice with CMake and is also great for embedded.
Title: Re: General IDE to learn C++ on
Post by: Simon on February 08, 2022, 02:00:09 pm
Just need something that when I compile a program and it does not work I know it is because of my code and not some sillyness in the IDE.

Going to build a separate machine to run Linux on so maybe I'll get more sense on that.
Title: Re: General IDE to learn C++ on
Post by: alexanderbrevig on February 08, 2022, 03:57:59 pm
Just need something that when I compile a program and it does not work I know it is because of my code and not some sillyness in the IDE.

Neovim. Thank me later.
No really. Give it a day and fall in love.
Title: Re: General IDE to learn C++ on
Post by: Ed.Kloonk on February 08, 2022, 10:23:28 pm
Just need something that when I compile a program and it does not work I know it is because of my code and not some sillyness in the IDE.

Neovim. Thank me later.
No really. Give it a day and fall in love.
Interesting project.
Title: Re: General IDE to learn C++ on
Post by: nigelwright7557 on August 02, 2022, 02:33:59 pm
VS may be fine but the OP explicitely stated that he didn't want it. This didn't look very hard to get. :popcorn:
VS community is a HUGE install, even if you selectively disable everything not strictly needed for basic C++ dev (which takes a while and you're not even sure what will be needed or not), because by default it's even more huge. Gigantic.

Despite VS not being wanted I would totally disagree with that stance.
VS is an incredible piece of software with intellisense to guide you.
I have used it for 20 years and done some huge programs with it.
Title: Re: General IDE to learn C++ on
Post by: emece67 on August 02, 2022, 03:29:55 pm
.
Title: Re: General IDE to learn C++ on
Post by: rstofer on August 02, 2022, 03:33:26 pm
Just need something that when I compile a program and it does not work I know it is because of my code and not some sillyness in the IDE.

Going to build a separate machine to run Linux on so maybe I'll get more sense on that.

Linux is a great development environment.  Get pretty good with makefiles and you can build some large projects with files in separate directories and all that kind of thing.  The problem is, Linux may not be the target.  If Windows comes into the deal at all, it is probably better to develop on Windows and the Visual Studio Code (and let's be clear, this isn't Visual Studio with all the compilers and such) is a pretty nice IDE.  There is a difference between Visual Studio and Visual Studio Code although the IDE portion of Visual Studio looks a lot like Visual Studio Code.

Mostly, we build console apps (at least that is the case for me) and those will run in the terminal window of VSC where you can see the results and any error messages.  And, yes, they will be YOUR errors, not the IDEs.  You have to figure that the millions of people using VSC will have discovered any issues long before you came to play.

I also like Eclipse, mainly because it has a Fortran plug-in.  Again, the command line output is at the bottom of the screen.  This is a very workable IDE and used by MANY programmers.
Title: Re: General IDE to learn C++ on
Post by: nctnico on August 02, 2022, 03:51:44 pm
VS Code seems to be the popular IDE 'du jour' but what I like about Eclipse CDT is that it has many goodies out of the box. In order to get the same level of functionality from VS code, you'll need to install several plugins for which you need to know which ones are good and which aren't. Not very helpfull if you are a novice.
Title: Re: General IDE to learn C++ on
Post by: rstofer on August 02, 2022, 04:05:17 pm
On Linux, I use gedit or geany as the editor and a separate terminal for build and execution.  So, two windows open on the screen.  It doesn't get easier than this.

The Raspberry Pi makes a pretty decent Linux environment and a Pi 400 is very convenient if desk space is available.  The cool part is to set up VNC and run the whole Linux process from a Windows workstation, graphics desktop and all.  Running a Pi headless is very workable and there is no reason to give up desk space for another monitor/keyboard/mouse setup.  Getting started may require a monitor/keyboard/mouse or not.  If you can use a wired network connection (because the new headless Pi won't have the WiFi ssid/password) and your router will give you the IP address, you can even start headless.  Search Google for ideas about getting the Pi IP address.  Turns out my HP desktop has HDMI input so I can use the same display for the All-In-One or the Pi.  Still have to diddle around with the keyboard/mouse.  I guess I could use a KVM switch but I'm lazy.  I only need the Pi keyboard/mouse for a couple of minutes to set up WiFi and VNC.




Title: Re: General IDE to learn C++ on
Post by: eti on October 12, 2022, 06:44:30 pm
I use Ubuntu as my OS. I installed Windows 10, 2 days ago, to write a C# forms application... wow... the amount of time it took to JUST get the OS to behave, to ACTUALLY SHUTDOWN (messed around with the "Intel Management Engine Interface" driver for over an hour and the machine still wouldn't power off, black screen, fans whizzing) - then the next day, just as I was doing something it shut itself down!

So yeah, a vote for Linux is a deffo! g++ for the win!
Title: Re: General IDE to learn C++ on
Post by: JPortici on October 14, 2022, 04:56:25 am
Uh, i missed this.
If i had to i'd use the Qt Ide, but that's because i'm already using Qt so i have the IDE, compiler, debugger already in place. In Qt i can create a c++ project without using a single Qt feature if i want to
Earlier i would have used visual c++. Same reason, i was already using C# to do .net applications so i already had visual studio installed
Generic IDE, probably eclipse for as much as i dislike eclipse it just works(tm) for C++, or VSCode if i ever manage to understand how to make it work like an ide and interact with a debugger
Title: Re: General IDE to learn C++ on
Post by: orb on January 12, 2023, 09:34:38 am
Windows: you can use cygwin + notepad++.
Linux: gcc + geany.
Android: termux (clang) + quickedit.

Termux is a very powerful environment, I use it for python too. I used VS a long time ago, because it is a good option for programming in the windows api.
Title: Re: General IDE to learn C++ on
Post by: Ian.M on January 12, 2023, 10:19:13 am
Caution: Cigwyn (and also various GCC based toolchains) can break totally unrelated Windows CMD scripts (.bat, .cmd).   The culprit is often the FIND command, which has very different syntax in its Linux and Windows command line versions.   You can reorder the path so the Windows version comes first, but that will break any shell script that is expecting Linux FIND syntax.  |O

After wasting an afternoon debugging such a CMD script that had mysteriously broken since I last used it some 15 month earlier, I ended up replacing all occurrences of find in it with %SystemRoot%\System32\find to explicitly invoke the Windows version!  :horse:
Title: Re: General IDE to learn C++ on
Post by: Sherlock Holmes on January 12, 2023, 05:30:49 pm
I have "the book" "Programming principles and practice using C++" by Bjarne Stroustrup. It has example and exercises and he recommends visual studio but this was in 2005. Visusual studio or whatever it is called now it rather bloated for running a few lines of code. Anything else worth using?

Visual Studio is a superb application though, very very robust, very well maintained, runs on Mac too. The overall robustness, cutting edge extension support and powerful debugging of multithreaded and asynchronous code is just win-win-win.

The community edition is free too!
Title: Re: General IDE to learn C++ on
Post by: IanB on January 13, 2023, 02:24:30 am
Caution: Cigwyn (and also various GCC based toolchains) can break totally unrelated Windows CMD scripts (.bat, .cmd).   The culprit is often the FIND command, which has very different syntax in its Linux and Windows command line versions.   You can reorder the path so the Windows version comes first, but that will break any shell script that is expecting Linux FIND syntax.  |O

After wasting an afternoon debugging such a CMD script that had mysteriously broken since I last used it some 15 month earlier, I ended up replacing all occurrences of find in it with %SystemRoot%\System32\find to explicitly invoke the Windows version!  :horse:

Here is a useful little command script to help with this situation. It reproduces the Unix "which" command by telling you which program will run when you enter a command, for example:
Code: [Select]
C:\Temp>which notepad
C:\Windows\System32\notepad.exe

C:\Temp>which find
C:\Windows\System32\find.exe

C:\Temp>which cl
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\bin\Hostx86\x86\cl.exe

C:\Temp>which perl
C:\Strawberry\perl\bin\perl.exe

C:\Temp>which which
C:\Tools\which.cmd

C:\Temp>

The script is listed below. Place it in a file called "which.cmd" and place it somewhere suitable in your path. I like to use C:\Tools for this kind of thing.
Code: [Select]
:: which.cmd
::
:: Locates which version of a command will run given the current search path
::
@echo off
setlocal enableextensions

set command=%1

if "%command:~0,1%"=="/" (
    echo Finds and prints the location of the program that will execute a given command
    echo given the current search path. Convenient to find out if the expected version
    echo of a command is the one that will run.
    echo.
    echo WHICH [command]
    echo.
    echo For example,
    echo.
    echo     which notepad
    echo.
    echo will likely display
    echo.
    echo   C:\Windows\System32\notepad.exe
    exit /b 0
)

if "%command%"=="" (
    echo Usage: which command
    exit /b 0
)
::
:: Set things up
::
set extlist=%pathext%
set found=false
set localpath=%cd%;%path%

::
:: Loop over all possible command extensions
::
:extloop
if "%extlist%"=="" exit /b 1

call :getnext

call :lookforit %command%%ext%
if %found%==true exit /b 0
goto :extloop

::
:: Subroutine to get next available command extension from list
::
:getnext

for /f "delims=; tokens=1,*" %%i in ("%extlist%") do (
  set ext=%%i
  set extlist=%%j
)

goto :eof

::
:: Subroutine to locate a given command+extension in the search path
::
:lookforit

set fullpath=%~$localpath:1
if "%fullpath%"=="" goto :eof

echo %fullpath%
set found=true
goto :eof