# C Compiler under Fedora

**URL:** <https://boards.straightdope.com/t/c-compiler-under-fedora/604323>\
**Category:** Factual Questions\
**Created:** [November 28, 2011, 6:03am UTC](https://boards.straightdope.com/t/c-compiler-under-fedora/604323 "2011-11-28T06:03:55Z")\
**Posts on this page:** 16\
**Page:** 3

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [November 30, 2011, 6:28pm UTC](https://boards.straightdope.com/t/c-compiler-under-fedora/604323/41 "2011-11-30T18:28:12Z")

</div>

> [@](#):
>
> Quoth **Derleth** :  
> No, this is not true on a purely factual level. There are a lot of C constructs that are good practice in C but invalid in C++.

Can you give some examples? I have not to my knowledge encountered this.

---

<div class="post-metadata">

**Author:** ![Rysto](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@Rysto](https://boards.straightdope.com/u/Rysto)\
**Post date:** [November 30, 2011, 6:45pm UTC](https://boards.straightdope.com/t/c-compiler-under-fedora/604323/42 "2011-11-30T18:45:10Z")

</div>

Well, ignoring the existence of C99 (which the C++ standardization committee is certainly doing), even something as simple as:

int \*a = malloc(sizeof(int));

will fail to compile with a type error.

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [November 30, 2011, 6:51pm UTC](https://boards.straightdope.com/t/c-compiler-under-fedora/604323/43 "2011-11-30T18:51:12Z")

</div>

> [@Chronos](#):
>
> Can you give some examples? I have not to my knowledge encountered this.

Sure. This is a valid C program which is not valid C++:

```auto

#include <stdlib.h>
#include <stdio.h>

int main(void)
{
    int *buf;

    if (!(buf = malloc(23 * sizeof(*buf))))
        exit(EXIT_FAILURE);

    buf[0] = 5;

    printf("%d
", buf[0]);

    free(buf);

    return 0;
}

```

The problem (from the C++ perspective) is that I didn’t cast the return value of malloc(); that’s actually bad practice in C, as it can mask a failure to include stdlib.h and, worse, cause the compiler to treat the void\* as an int before casting it back to a pointer. On 64-bit systems, where pointers are 64-bit but ints are typically 32-bit, this can be utterly catastrophic.

I could probably think of more, and worse, examples, but that example is, to me, emblematic of a serious underlying problem with how C++ extended C: It tried to make the type system ‘stricter’ but only succeeded in making it more annoying. You still have all (or almost all) of the same ‘type system escape hatches’ you do in C, so the compiler can’t necessarily optimize any better, but it tends to raise the meaningless error message noise floor unless your program really does fit cleanly into how C++ wants to do things.

---

<div class="post-metadata">

**Author:** ![Testy](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@Testy](https://boards.straightdope.com/u/Testy)\
**Post date:** [November 30, 2011, 9:42pm UTC](https://boards.straightdope.com/t/c-compiler-under-fedora/604323/44 "2011-11-30T21:42:30Z")

</div>

> [@Senegoid](#):
>
> Then you are clearly **waaaaaaaaaaay** beyond what any Dummies-type of book could do for you. I’m less certain now of just what kind of help you are asking for. It’s perfectly clear that you can find and study on-line tutorials or printed books on your own. But I’m wondering now if you had more specific, or more advanced, or more technical questions in mind. Like maybe something about how to set up data structures or objects to deal with bit-fields in MP3 files, or something detailed like that. (In which case, I’m not necessarily the one to help you. I never really got all into object-oriented programming that deeply. I was actually more of a FORTRAN-and-assembly-language nerd back in the 70’s.)
> 
> [sup]And I wrote big hungus TECO macros when I wasn’t out in the rain feeding the dolphins.[/sup]

**Senegoid**

You’re right on me being past the “Dummies” stage. I took a look through it last night and, as you and **Derleth** pointed out, the thing is a wretched waste of money.  
I expect to have some specific questions when I actually get some of this stuff running. (I’m just vacuming-out and replacing some cards in my old PC right now) I think I may need something more in the line of generic programming. By that, I mean something that teaches me how to make an efficient and reliable program along with the best practices on doing things. I have written programs before, as I mentioned, but I was well aware that I was substituting persistence for knowledge. They worked in the end but were somewhat of a kludge. I picked C/C++ as they are standard and there is a huge body of knowledge on using them.  
I used to write some hex fat-finger programs but you can bet they didn’t do much. Were you doing any kind of work with the dolphins? Or just enjoying them? I used to watch them body-surfing on the bow wave of the boat and loved those things.

Regards

Testy

---

<div class="post-metadata">

**Author:** ![Testy](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@Testy](https://boards.straightdope.com/u/Testy)\
**Post date:** [November 30, 2011, 9:53pm UTC](https://boards.straightdope.com/t/c-compiler-under-fedora/604323/45 "2011-11-30T21:53:48Z")

</div>

> [@Derleth](#):
>
> **Testy** : So you want to learn C++ more than you want to learn C, then? They’re not the same language; even aside from the obvious technical changes, _idiomatic_ C++ is vastly different from _idiomatic_ C, just like Java and C# have a different style than C++.
> 
> Templates are a big part of this: C++ has a way to do ‘generic programming’ such that you can have, say, a single ‘sum()’ function that works the same way for _all numeric types_, something you really can’t do in C. This greatly influences how programs are structured.
> 
> And then, of course, there’s objects, operator overloading, a lot of new standard functions, new standard types, and other aspects I’m sure I’m missing. My point is, C++ is a new language and really needs to be approached as such.
> 
> [Bjarne Stroustrup agrees with me in this PDF titled “Learning Standard C++ as a New Language”.](http://www.research.att.com/~bs/new_learning.pdf) (Bjarne Stroustrup is the guy who invented C++.)  
> Also, **Senegoid** is right: If you know how to write working C code, you’re well beyond the “For Dummies” stage. If you want some help getting back up to speed on C, especially on a Unix-like platform, I likely know enough to answer your questions. I’m not nearly as good with C++.  
> Also, the C++ compiler in the GCC family is called g++; gcc only works on C.

**Derleth**  
Well, color me embarrassed. I had made an assumption there that C++ being a newer language, was simply a superset of standard C. Now I ansure which, if either, would be usable for my purposes. I do apologize but most of your post is well over my head. For now, I think I will set my sights a bit lower and try to regain some knowledge of C and see what I can do with it. I will probably become a pest as the days go by.

Thank you

Testy

---

<div class="post-metadata">

**Author:** ![Senegoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/senegoid/32/6606_2.png) [@Senegoid](https://boards.straightdope.com/u/Senegoid)\
**Post date:** [December 1, 2011, 2:02am UTC](https://boards.straightdope.com/t/c-compiler-under-fedora/604323/46 "2011-12-01T02:02:20Z")

</div>

> [@Francis\_Vaughan](#):
>
> Take this from someone who codes C++ daily for a living. You don’t want to learn C++. If you want to mess about with MP3 file internals C is very likely a better answer anyway. C++ is pretty much the wrong answer to any question except “what are lousy languages.”
> 
> \<snip\>
> 
> Try [here](http://yosefk.com/c++fqa/) for why.

Yikes! This guy really wrote an encyclopedia on the problems of C++ didn’t he.  
This really will encourage all comers to think twice (or more) before diving in.

My own knowledge of C++ goes only slightly beyond the “Hello World” level (but still well beyond the Dummies level), yet I had already started to notice at least a few of the problems he discusses.

This sooooooo much reminds me of Kernighan’s classic paper [Why Pascal is Not My Favorite Programming Language](http://www.lysator.liu.se/c/bwk-on-pascal.html) only it looks like 10 times more so. (And I just spent a few minutes skimming a few pages of it.)

He really makes some scathing points, to the effects that  
(a) For any type of project that you might wish to do with C++ you could do it better and easier either with plain-old-C or, if you really need OOP, then with Java or some other OOP language.  
(b) Even for a highly experienced C++ programmer, it will be easier to learn a different OOP language from scratch and use it, rather than use C++  
(c) Perhaps the only real justification for using C++ is where you have to work on an already-existing project that is already done in C++

[sup]Give me a little more time and I’ll write up something about what I was doing with all those dolphins. Hint: There were only two of them, actually, and involved language research, but we didn’t have C++ in those days. In the meantime, see [http://www.dolphin-institute.org/](http://www.dolphin-institute.org/) and in particular [http://www.dolphin-institute.org/our\_research/index.htm[/sup]](http://www.dolphin-institute.org/our_research/index.htm%5B/sup%5D)

---

<div class="post-metadata">

**Author:** ![Testy](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@Testy](https://boards.straightdope.com/u/Testy)\
**Post date:** [December 1, 2011, 3:19pm UTC](https://boards.straightdope.com/t/c-compiler-under-fedora/604323/47 "2011-12-01T15:19:58Z")

</div>

> [@Senegoid](#):
>
> Yikes! This guy really wrote an encyclopedia on the problems of C++ didn’t he.  
> This really will encourage all comers to think twice (or more) before diving in.
> 
> My own knowledge of C++ goes only slightly beyond the “Hello World” level (but still well beyond the Dummies level), yet I had already started to notice at least a few of the problems he discusses.
> 
> This sooooooo much reminds me of Kernighan’s classic paper [Why Pascal is Not My Favorite Programming Language](http://www.lysator.liu.se/c/bwk-on-pascal.html) only it looks like 10 times more so. (And I just spent a few minutes skimming a few pages of it.)
> 
> He really makes some scathing points, to the effects that  
> (a) For any type of project that you might wish to do with C++ you could do it better and easier either with plain-old-C or, if you really need OOP, then with Java or some other OOP language.  
> (b) Even for a highly experienced C++ programmer, it will be easier to learn a different OOP language from scratch and use it, rather than use C++  
> (c) Perhaps the only real justification for using C++ is where you have to work on an already-existing project that is already done in C++
> 
> [sup]Give me a little more time and I’ll write up something about what I was doing with all those dolphins. Hint: There were only two of them, actually, and involved language research, but we didn’t have C++ in those days. In the meantime, see [http://www.dolphin-institute.org/](http://www.dolphin-institute.org/) and in particular [http://www.dolphin-institute.org/our\_research/index.htm[/sup]](http://www.dolphin-institute.org/our_research/index.htm%5B/sup%5D)

**Senegoid**

Well, by all accounts it seems that I am better off and possibly more productive if I restrict myself to C instead of C++ so I think I will do that for now. Thank you for all your help and advice on this.

_When you mentioned the dolphins I thought you might have been working with Dr. John C. Lily. “Wow man, look at the colors!”_😃

Regards

Testy

---

<div class="post-metadata">

**Author:** ![Senegoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/senegoid/32/6606_2.png) [@Senegoid](https://boards.straightdope.com/u/Senegoid)\
**Post date:** [December 2, 2011, 11:29am UTC](https://boards.straightdope.com/t/c-compiler-under-fedora/604323/48 "2011-12-02T11:29:34Z")

</div>

> [@Testy](#):
>
> **Senegoid**
> 
> Well, by all accounts it seems that I am better off and possibly more productive if I restrict myself to C instead of C++ so I think I will do that for now. Thank you for all your help and advice on this.
> 
> _When you mentioned the dolphins I thought you might have been working with Dr. John C. Lily. “Wow man, look at the colors!”_😃
> 
> Regards
> 
> Testy

Yes, the general scuttlebutt I have been hearing about C++ for a few years now, is that C is better. That said, C was always known as a programming language that was too easy to make too many obsure bugs, for a variety of reasons (and C++ as we’ve seen didn’t solve a lot of that as it aimed to do). For the size and complexity that today’s really major apps have become, and for the really critical nature of some of them (guiding rockets to Mars, controlling medical devices, controlling industrial processes, etc.), and given the increasing speed of CPU’s so that execution efficiency is not always so critical, the need has become apparent to have programming languages and disciplines that facilitate really accurate bug-free (as possible) programming. OOP is supposedly a big step forward in this. And so is the idea of “managed execution environments” that the above-mentioned article talks about so much.

[total hijack follows]  
Now that **Testy** seems satisfied with all our answers to his OP, we can talk about other _interesting_ stuff, right? About the same time John Lilly was doing his well-known work with teaching dolphins to say “Fa loves Pa” in psychedelic technicolor, Louis Herman of the University of Hawaii was studying dolphin language acquisition at Kewalo Basin Marine Mammal Laboratory. [Yes, that is the lab mentioned in that _Onion_ satire about [dolphins growing opposable thumbs.](http://www.theonion.com/articles/dolphins-evolve-opposable-thumbs,284/)] – I worked there from 1981 through 1984, mostly doing programming (mostly in Apple II Basic), but I also participated in the training, care and feeding, and research sessions with the dolphins. On weekends, we cleaned the tank and after that people went swimming with them. Pretty much everybody disappeared for the Christmas/NewYear week each year, but I lived at the lab and didn’t go anywhere. So on Christmas Day one year, I was the ONLY one there. It was pouring rain, and I was out there with nothing on but trunks and sandals, feeding the dolphins. In Hawaii, you can be out in the rain like that, even on Christmas, without getting very cold. It was merely comfortably cool. I think the lab still exists but with a different name and in a newer location now. ETA: We tended to think of Lilly’s work as [del]kind of[/del] a laughing stock.

[sup]Yes, Lilly has acknowledged that he gave LSD to his dolphins too.[/sup]

---

<div class="post-metadata">

**Author:** ![Jragon](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@Jragon](https://boards.straightdope.com/u/Jragon)\
**Post date:** [December 2, 2011, 12:20pm UTC](https://boards.straightdope.com/t/c-compiler-under-fedora/604323/49 "2011-12-02T12:20:02Z")

</div>

> [@griffin1977](#):
>
> Yeah, its all C underneath, so the compiler is unimportant.
> 
> If the whole command-line/makefile thing is a bit much for you (I know its a bit much for me at times 🙂 ) you should get an IDE which wraps the compile in something a bit easier to understand.
> 
> I’d recommend [CodeBlocks](http://www.codeblocks.org/) or [Eclipse](http://www.eclipse.org/).

I’d recommend heavily against Eclipse. Eclipse is wonderful for Java, but every time I’ve tried to use Eclipse for C/C++ it’s been an utter nightmare and roller coaster of unfun. Even the interface for creating a new C-file or project is confusing and can take some tinkering to work. On several installs of various OSs I’ve even had issues getting the default toolchains to work, and if there’s one thing you don’t want a newbie (or hell, most experienced programmers) working with, it’s toolchains.

Using an IDE makes things better for enterprise applications, but for any small-medium sized project I think finding a good text editor with C highlighting, and then learning how to use make properly is far superior for no reason other than you don’t have to figure out whether it’s you or your IDE that’s making your code fail to compile in strange new ways.

---

<div class="post-metadata">

**Author:** ![Testy](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@Testy](https://boards.straightdope.com/u/Testy)\
**Post date:** [December 2, 2011, 4:06pm UTC](https://boards.straightdope.com/t/c-compiler-under-fedora/604323/50 "2011-12-02T16:06:06Z")

</div>

> [@Jragon](#):
>
> I’d recommend heavily against Eclipse. Eclipse is wonderful for Java, but every time I’ve tried to use Eclipse for C/C++ it’s been an utter nightmare and roller coaster of unfun. Even the interface for creating a new C-file or project is confusing and can take some tinkering to work. On several installs of various OSs I’ve even had issues getting the default toolchains to work, and if there’s one thing you don’t want a newbie (or hell, most experienced programmers) working with, it’s toolchains.
> 
> Using an IDE makes things better for enterprise applications, but for any small-medium sized project I think finding a good text editor with C highlighting, and then learning how to use make properly is far superior for no reason other than you don’t have to figure out whether it’s you or your IDE that’s making your code fail to compile in strange new ways.

**Jragon**

Against the good advice of several people in the thread, I D/Led Code Blocks and gave it a try. They were right and you are right. It is a PITA and I think I would wind up learning more about the IDE than C.  
In any event, I certainly don’t need an IDE for the “Hello World” level of programs I am doing at the moment.

Thanks and regards

Testy

---

<div class="post-metadata">

**Author:** ![Testy](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@Testy](https://boards.straightdope.com/u/Testy)\
**Post date:** [December 2, 2011, 4:13pm UTC](https://boards.straightdope.com/t/c-compiler-under-fedora/604323/51 "2011-12-02T16:13:00Z")

</div>

> [@Senegoid](#):
>
> Yes, the general scuttlebutt I have been hearing about C++ for a few years now, is that C is better. That said, C was always known as a programming language that was too easy to make too many obsure bugs, for a variety of reasons (and C++ as we’ve seen didn’t solve a lot of that as it aimed to do). For the size and complexity that today’s really major apps have become, and for the really critical nature of some of them (guiding rockets to Mars, controlling medical devices, controlling industrial processes, etc.), and given the increasing speed of CPU’s so that execution efficiency is not always so critical, the need has become apparent to have programming languages and disciplines that facilitate really accurate bug-free (as possible) programming. OOP is supposedly a big step forward in this. And so is the idea of “managed execution environments” that the above-mentioned article talks about so much.
> 
> [total hijack follows]  
> Now that **Testy** seems satisfied with all our answers to his OP, we can talk about other _interesting_ stuff, right? About the same time John Lilly was doing his well-known work with teaching dolphins to say “Fa loves Pa” in psychedelic technicolor, Louis Herman of the University of Hawaii was studying dolphin language acquisition at Kewalo Basin Marine Mammal Laboratory. [Yes, that is the lab mentioned in that _Onion_ satire about [dolphins growing opposable thumbs.](http://www.theonion.com/articles/dolphins-evolve-opposable-thumbs,284/)] – I worked there from 1981 through 1984, mostly doing programming (mostly in Apple II Basic), but I also participated in the training, care and feeding, and research sessions with the dolphins. On weekends, we cleaned the tank and after that people went swimming with them. Pretty much everybody disappeared for the Christmas/NewYear week each year, but I lived at the lab and didn’t go anywhere. So on Christmas Day one year, I was the ONLY one there. It was pouring rain, and I was out there with nothing on but trunks and sandals, feeding the dolphins. In Hawaii, you can be out in the rain like that, even on Christmas, without getting very cold. It was merely comfortably cool. I think the lab still exists but with a different name and in a newer location now. ETA: We tended to think of Lilly’s work as [del]kind of[/del] a laughing stock.
> 
> [sup]Yes, Lilly has acknowledged that he gave LSD to his dolphins too.[/sup]

**Senegoid**  
Thank you for everything. I think I’ve got what I need to be going on with now.

[continuing total hijack] So, are dolphins as personable as they are made to seem? I’ve never had anything to do with them aside from watching a few wild ones. And giving a dolphin LSD seems a very assholish thing to do. What the hell was he thinking? Or was his brain too fried by that point?[/total hijack]

Best regards and many thanks

Testy

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [December 2, 2011, 8:18pm UTC](https://boards.straightdope.com/t/c-compiler-under-fedora/604323/52 "2011-12-02T20:18:42Z")

</div>

> [@](#):
>
> Quoth **Senegoid** :  
> Yes, the general scuttlebutt I have been hearing about C++ for a few years now, is that C is better.

Huh, that makes me feel a lot better about having never bothered to learn C++.

---

<div class="post-metadata">

**Author:** ![Senegoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/senegoid/32/6606_2.png) [@Senegoid](https://boards.straightdope.com/u/Senegoid)\
**Post date:** [December 3, 2011, 9:34am UTC](https://boards.straightdope.com/t/c-compiler-under-fedora/604323/53 "2011-12-03T09:34:35Z")

</div>

**Testy** , here is a whole threadfull of recommendations for programming languages you should NOT learn! [http://boards.straightdope.com/sdmb/showthread.php?p=14525728](http://boards.straightdope.com/sdmb/showthread.php?p=14525728)

---

<div class="post-metadata">

**Author:** ![Testy](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@Testy](https://boards.straightdope.com/u/Testy)\
**Post date:** [December 3, 2011, 7:04pm UTC](https://boards.straightdope.com/t/c-compiler-under-fedora/604323/54 "2011-12-03T19:04:20Z")

</div>

> [@Senegoid](#):
>
> **Testy** , here is a whole threadfull of recommendations for programming languages you should NOT learn! [http://boards.straightdope.com/sdmb/showthread.php?p=14525728](http://boards.straightdope.com/sdmb/showthread.php?p=14525728)

**Senegoid**

Yikes! Oddly enough, I have seen almost all of those languages promoted as God’s gift to programmers at one time or another, usually when they first came out. I actually messed around with Fortran at one time. Fortran IV, I think. That was using actual Hollerith cards and an incredibly dumb terminal. I felt like a lottery winner every time something actually worked.

Regards

Testy

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [December 3, 2011, 7:06pm UTC](https://boards.straightdope.com/t/c-compiler-under-fedora/604323/55 "2011-12-03T19:06:52Z")

</div>

Well, to be fair, at the time Fortran was head-and-shoulders above anything else available. I mean, it was basically Fortran, COBOL, or assembly.

---

<div class="post-metadata">

**Author:** ![Testy](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@Testy](https://boards.straightdope.com/u/Testy)\
**Post date:** [December 3, 2011, 7:16pm UTC](https://boards.straightdope.com/t/c-compiler-under-fedora/604323/56 "2011-12-03T19:16:35Z")

</div>

> [@Chronos](#):
>
> Well, to be fair, at the time Fortran was head-and-shoulders above anything else available. I mean, it was basically Fortran, COBOL, or assembly.

**Chronos**

Weirdly enough, at the time I actually found it easier to do machine code on a PDP-11. I’ve never had anything at all to do with COBOL but I understand it is still used a lot for business purposes.

Regards

Testy

[Previous page](https://boards.straightdope.com/t/c-compiler-under-fedora/604323.md?page=2)
