Not knowing how to insert flags

So someone from another question I asked introduced me to this:

g++ -std=c++2a -Werror -Wall -Wextra -Wpedantic -Wshadow main.cpp -o main.exe

He said he uses a windows porting of GCC compiler, and by using this flag, he gets a lot of warnings regarding my code. Unfortunately, he didn't reply when I asked how to add the flag, so here I am, since knowing how to get the warnings will really ease the effort of looking for errors. I myself am using Dev C++ in windows, with TDM-GCC compiler.
Last edited on
I do not know Dev C++ but all IDEs work similar. Somewhere in your project settings you should have a place to manually add compiler flags that will be applied when building your project. You may need to read your help or google a screenshot on where exactly that is.

Some compilers have converted many common flags to check boxes or the like, visual studio does this, makeing it easier to enable and disable them rapidly with a click instead of remembering all the text to type. Either way, they all support just typing them in.

Dev c++ may be using an older version of c++, I think someone said it was stuck in 2011 (2017 is almost done and 2020 is around the corner!).

Hi jonnin,

So it's only applicable on project, not on source file?
Yes Dev C++ is old, I wanted to use visual studio but even after I installed the plugins I don't know how to use them, and I was in a rush to complete my code so I didn't have time to watch videos on how to use visual studio.
There should be "Compiler settings" or similar in some menu in Dev-C++. You aren't going to have -std=c++2a, since that's too new, but the other -W warnings should still apply.
Read: https://stackoverflow.com/a/16951613

Dev-C++ either has a check list, or has
What's important is:
-Wall -Wextra -Wpedantic -Wshadow

There should either be checkboxes to enable these warnings, or something like that.

If there aren't checkboxes, there should be some menu option to add custom flags. -Wall is the most important, but the others help too.
Last edited on
Hi Ganado, so there's limited options I see, my C++ options list only doesn't have -Wshadow, there's a section for me to enter commands when compiling though, can I add it there?
Can I ask another question? Not a code question but just general stuffs, or do I start another post?
depends on how involved it is. If its worthy of a new topic, make a new one. If its just something simple leave it here is fine.

its faster to try stuff than to ask. But yes, if you think you found the place to type it, give it a try. It will happily do one of 3 things: complain, work, or do nothing.
Hi jonnin,

Just wanna know what's the difference between compiling at 32-bits and 64-bits.
Yeah if there's text you can enter for custom flags, try it out.
Hi Ganado,
Thanks for your help!
Just wanna know what's the difference between compiling at 32-bits and 64-bits.

Your CPU is either 32 or 64 bit, this is a hardware thing where the size of a register (integer) is 64 bits instead of 32 bits; that is the CPU can do math on a 64 bit int in a single instruction, rather than emulate it splitting it into 2 32 bit chunks which is much slower. It can address 2^64 bytes of memory, rather than 2^32, and other similar things are affected. That is why 32 bit machines can't have very much ram in modern terms, limited to 4gb.

Your OS can be 32 bit on a 64 bit machine, and it will do some things like memory management as if it were a 32 bit machine. A 32 bit os on a 64 bit machine is not using the hardware well.

Compiling your programs in these modes target these systems. A 32 bit compile will work on a Pentium generation 1 running windows 95. A 64 bit build will work on modern OS and hardware. You should use 64 bit unless you need to target an antique or embedded (eg phone or device? ) platform that is still running 32 bit (becoming more and more rare). Most 64 bit systems can run programs compiled for 32 bit mode for backwards compatibability. 64 bit compiles will NOT work on 32 bit machines.

Last edited on
Hi jonnin,

So that's why 64-bits is usually better than 32-bits. Thanks for the clarification.
Topic archived. No new replies allowed.