DEV Community

Discussion on: How a C/C++ code is compiled in a system?

Collapse
 
pauljlucas profile image
Paul J. Lucas

I recommend you to use GNU's GCC Compiler as it's standard and widely used.

It's not standard. There's no standards body that standardizes compilers. Widely used? Yes. Standard? No.

cout << "Hello World!";

Missing \n.

... using -S flag ...

You really should check this out.

... do note that it differs across compilers used ...

It also differs on the platform, CPU, and optimization level used.

You also should really talk about name mangling.

Collapse
 
alphax86 profile image
Aadhitya A

Hey Paul, thanks for your comment and your tip. I'll recheck all again and edit the blog post accordingly. Thanks for your quick response and your tip

Collapse
 
tiagomelojuca profile image
Tiago Melo Jucá

"GCC is not standard"
Well, it's a lot compliant. It does has some faults. And probably the software we write too. It happens. There is not standards for compilers? This sounds exactly what the C++ standard should be. And this is why if you find something non compliant about GCC, you can just open a bug request.

Missing new line character for a low level article? Omg, seriously?

I do agree Compiler Explorer is great, but there is no problem at all in using -S flag for any explanation. A lot of blog posts do this, and just because we have a nice tool for studying compilers, doesnt mean -S is useless. Actually, to begginers, it's nice teach about this feature.

And yes, he could talk about name mangling. Also, he could talk about the ABI. Also, about parsing, generating the Abstract Syntax Tree, linking, dynamic/static linking differences... and it goes on. Finally, he could write a book and draw a dragon as cover, couldn't he? C'mon.

About differences across platforms, cpu, and opt level, when I read the statement was already there, but probably it was your tip. This was a good one.

Criticism is good, but sorry, in this case, most is just pointless. Are you trying to prove you're smart? I'm pretty sure you are (I'm not being ironic at all here). That said, there are better ways to achieve this :)

Collapse
 
pauljlucas profile image
Paul J. Lucas

There is not standards for compilers?

Correct.

This sounds exactly what the C++ standard should be.

No. Any language standard can only standardize the language itself, not compilers.

And this is why if you find something non compliant about GCC, you can just open a bug request.

True, but irrelevant. Compliance to a standard is not the same thing as a standard.

Suppose there is a standard for a wrench. A standards body wrote that standard. Manufacturer X can make X's wrench that conforms to that standard. Manufacturer Y can make Y's wrench that also conforms to that standard. However, the standards body does not standardize either X's or Y's wrench. Again, they write only the standard and do not standardize particular wrenches. A wrench can be standards-conforming, but that is not the same as being a standard itself.

Words matter, especially when it comes to computers. Words have precise meanings. Please learn what these words mean.

Missing new line character for a low level article? Omg, seriously?

So that gives you license to get it wrong? So, yes, seriously.

... but there is no problem at all in using -S flag for any explanation ...

I never said there was a problem. I'm saying that using Compiler Explorer is a lot better.

And yes, he could talk about name mangling. Also, he could talk about the ABI. Also, about parsing, generating the Abstract Syntax Tree, linking, dynamic/static linking differences... and it goes on. Finally, he could write a book and draw a dragon as cover, couldn't he? C'mon.

Of all those, name mangling is the relevant one since it would explain why names in the assembly output have different names. You obviously missed that point.

Criticism is good, but sorry, in this case, most is just pointless.

You're entitled to your opinion.