About compiler

Pages: 12
g++ -wall -g ....

What those called: -wall -g

Where can I find the full list of them, with usage description of them.

Thanks)
https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html

Most of the options work for C, C++ and fortran

-Wall is in the "Warning Options" section.
-g is in the "Debugging Options" section.

I shouldn't try to memorise all of them!
Last edited on
Thank you @lastchance,

I compiled this line using g++:
char ch = ' : ';

I got this error: multi-character constant [-Wmultichar], I also got a lot of those[-SOMETHING]
like [-Woverflow], [-Wunused-variable] ......

What those are called?
A char is a single character.

If you write
' : '
with single quotes then that is three chars: you are trying to create multi-chars.


Just use
std::string X = " : "
or any of the fancy uniform-initialisation equivalents (which I hate, because they have no counterpart in other languages).

Note the double, not single, quotes here.
Thank you @lastchance, but this is not what I ask here:

The following is what I ask about, what those inside the double brackets with the minus padded to them?

I got this error: multi-character constant [-Wmultichar], I also got a lot of those[-SOMETHING]
like [-Woverflow], [-Wunused-variable] ......

What those are called?
Inside [] it mentions the specific flag that enables this warning.

-Wall enables many warnings.

Some warnings are also enabled by default. Not sure if all of these are documented but there is normally a -Wno-... opposite to turn them off.

-Wmultichar is enabled by default. You can use -Wno-multichar to turn it off.
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmultichar

-Woverflow is enabled by default. You can use -Wno-overflow to turn it off.
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Woverflow

-Wunused-variable is enabled by -Wall.
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wunused-variable
Last edited on
Thanks @Peter that what I was looking for))

One last question, it seems that if I compile using Code::Blocks and g++ both of them output the same logging messages. I know that Code::Blocks uses g++, but how it retrieves those message from it? In other way how to direct those message to for example a file.txt?

I don't know exactly how it does it but there are often system specific functions that you can use to execute other processes and use "pipes" to read the output (or write input).
Last edited on
I don't know exactly how it does it but there are often system specific functions that you can use to execute other processes and use "pipes" to read the output (or write input).


I will need couple weeks to understand this)) I'm going to search a little bit, Like always thank you @peter)
Code::Blocks is open source software so if you really want to know how it does it you should be able to find it somewhere in its source code.
Code::Blocks is open source software so if you really want to know how it does it you should be able to find it somewhere in its source code.


I have the source code of code::blocks but I do not know how to do that.
https://cplusplus.com/forum/beginner/284897/#msg1235491
, I did not get this? what are you trying to imply here?
Last edited on
You are making a mountain out of a molehill.

If you want to know about Code::Blocks then ask a question with a title that includes Code::Blocks.

If you want to know about Code::Blocks then read their manual (try googling "code blocks manual").

Or better, just learn to use the command line (or shell in linux) and you can easily apply whatever options you like. If there's a particularly long option list then just put the compilation (yeah, pre-processor|compiler|assembler|linker if you must) commands in a batch file.

Your compiler is from the gnu compiler collection, accessed by the g++ command.
Last edited on
You first reply was actually an answer to what I asked, the other replies of yours did not answer any question I asked.

The second question already answered by peter, without mentioning any Code::blocks in the title to him, the third question, just gave me some insights I appreciate that, but your second replay seems irrelevant to the topic, I just want to know 2 things here:

what this link need to tell me? I am guess you're try to tell me that am pedant????
https://cplusplus.com/forum/beginner/284897/#msg1235491


The second question, how did you belt that link that lead directly to a message but not to page?
ninja01 wrote:
how did you belt that link that lead directly to a message but not to page?


Find the particular answer that you want to link directly to.

Right click the "link" icon (it's just before the original date of the post).

Choose "Copy link".

Paste (e.g. ctrl-V) anywhere you want.
Got it, and note you answered the question without me mentioned it in the title)

what about the first one?
ninja01 wrote:
Got it, and note you answered the question without me mentioned it in the title)

https://cplusplus.com/forum/beginner/284897/#msg1235491
Me worte:
but how it retrieves those message from it? In other way how to direct those message to for example a file.txt?


This is how:
g++ main.cpp 2> "d:\output.txt"


Thanks for the help)
Last edited on
If you can run man g++ then you have the manual of your installed version of g++ in front of you. You can search string in 'man'. Press '/' and type the string (and Enter). Then press 'n' to hop to next match.
Pages: 12