Any Good Guides on gcc?

In basic, I’d like a reference source about using the compiler and, most importantly, what exactly errors mean. I’m still a beginner so bits about code optimisation and compiler design are not needed at the moment.

Any suggestions would be much appreciated.


You likely want manual on right hand side under documentation.

Thanks, but the problem is that I couldn’t find anything explaining what the errors produced by the compiler mean. I think it’s pretty poor that software used by so many people doesn’t have this information in its official manual as it’s what new programmers need to fix their programs.

I totally agree. And unfortunately there is a long history of compilers with unhelpful error messages. Part of the reason for this is that there are hundreds if not thousands of ways to make a compiler complain and syntax errors are just one kind. Consequently compiler writers don’t tend to focus on user friendliness. I would also take a poke at the the GCC project and say that they have a history of placing ‘GNU-ness’ and portability over user-friendliness.

But let me re-emphasize that a really good place to start programming on Haiku is DarkWyrm’s programming series:


As you do more programming it will get easier.

… is probably closer to what you’re looking for. But realistically the diagnostics from GCC (and any other C compiler I’ve worked with) have a fairly transparent meaning. If figuring out what you should do in response to these diagnostics was a trivial mechanical step the compiler would do it automatically, but it isn’t and a guide book can’t help you to know what you meant.

A syntax highlighting editor may help if you find that you frequently make typographical mistakes, such as omitting one of a pair of parentheses.

Well I kind of disagree. I’ve seen compilers with much better error diagnostics, that even make suggestions for more common errors. It is certainly possible to write compilers that are more newb-friendly. These were Pascal compilers that are more used in universities. C and C++ compilers were historically more used in production, and less for beginners. I think more beginners start with Java, but there are still a lot of beginners who start with GCC.

A compiler can’t correct what you did wrong but statistically it can put more effort into identifying common errors and recommend the fix.

Syntax highlighting is a win. If only it could also check commas :slight_smile:

Is it possible to use syntax highlighting in Pe? I have the keywords set to change colours. Also, the reason why I wanted to look for a guide is that I was following the code in the Be Book as far as I was aware, to the letter. The compiler told me: no match for ‘*entry_ref &’. I searched the internet for no match errors, but they all refer to overloading functions. All that would be required is an explanation of what the compiler sees to display the error.

Yes GCC is real BAD on giving errors… it is one of the motivation because Apple & all are writing LLVM compiler… we simply have to wait it matures and that will be ported to Haiku… the end of gcc an it’s “syntax error at end of input”:

What the heck is GNU-ness?

As for error reporting, that has been a sore thumb for GCC (and many other compilers aswell) for quite some time and one which llvm/clang has certainly improved greatly on.

This is something GCC devs are aware of though and it’s on the roadmap, meanwhile there’s a new plugin (as part of gsoc I think) which allows you to use python for compiler warnings, code visualizations etc.

Apple did not create LLVM, it was started in 2000 and Apple jumped on the train in 2005, however them hiring Chris Lattner has certainly accelerated development. As for why Apple wants LLVM/Clang I say it’s mainly because it is BSD licenced and as such they can incorporate them into their proprietary solutions (xcode), like with webkit, instruments (dtrace with a gui), etc. While I’m not very impressed with the performance of code compiled with llvm/clang I really appreciate the capacity it’s jit compiler framework offers and all the places in foss where it has been used.

we simply have to wait it matures and that will be ported to Haiku… the end of gcc an it’s “syntax error at end of input”:[/quote]
Neither compiler is going away, and they are both improving day by day. As for what compiler Haiku will default to in the far future, who knows?

I not think GNU is to give GCC better error reporting… it is developed for… let say 20-30 years and they NOW want to solve this issue? Too late IMHO…

Apple likes LLVM/Clang other that for the better license for a commercial product (BSD) for the better diagnostic as GCC gave a bad impression on the perfect XCode IDE… what is “syntax error at end of input”?

I hope that the Haiku future compiler will be Clang as Haiku license is BSD-like, too…

Nonsense, particularly given that error reporting has already improved over the course of GCC’s existence, just like optimizations, compilation speed, lowering of memory usage etc etc.

Also, ‘GNU’ refers to the GNU operating system, which is a product of the Free Software Foundation (FSF). So ‘GNU’ isn’t running the development of GCC, and in reailty neither is FSF, since it’s done by the GCC steering committee. The steering committee in turn consists of representatives (full-time programmers working on GCC) from companies such as IBM, Red Hat, Cisco, CodeSourcery, amongst others. These companies rely heavily on GCC and therefore funds large parts of it’s development and also steer the direction of it’s development.

I hope that the Haiku future compiler will be Clang as Haiku license is BSD-like, too…[/quote]
Given Haiku’s use of GPL licenced bash rather than a BSD-licenced variant it seems obvious there’s no real licence zelotry amongst the Haiku devs. As such I trust that the Haiku devs will make any change of default compiler based upon technical/practical merits rather than licence (unless of course the licence makes it impractical, but that’s not the case here).

Comparing GCC with Clang/LLVM currently I come to the following conclusion:

Performance of generated code, GCC is better here, the vast majority of benchmarks I’ve seen/done gives GCC the upper hand, also GCC has some strong optimizations like PGO (profile guided optimization) which is not available on LLVM.

Speed of compilation, LLVM/Clang wins here, although the margin has been lowered slightly as GCC has become slightly faster and LLVM/CLang has become slightly slower in the past releases. Still I think LLVM/Clang will continue to hold the lead here.

Error reporting, LLVM/Clang is much better and most likely will remain much better since it’s pretty much ‘best of class’ in this area amongst compilers.

Compability, this is obviously the biggest stumbling point for defaulting to another compiler than GCC as GCC is the ‘de facto’ open source compiler and as such is what 99.9% of open source code targets. Meanwhile Clang/LLVM still suffers from a high rate of incompability with GCC and until this is rectified (it IS improving with each release) it really can’t be considered a viable alternative as a default.

Again, I fully trust the Haiku devs will look at compilers from a technical/practical standpoint and not through licence-tinted glasses and make their choice based upon that. In fact the choice of open source licence for Haiku is the least exciting part of the project in my eyes. I don’t really care if it’s MIT/BSD, GLPV2/3, CDDL or whatever as long as it’s open source and continues to be such an awesome desktop solution :smiley: