Announcement

Collapse
No announcement yet.

The Linux Kernel Now Explicitly Uses GNU89, Not Yet C11 Friendly

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • The Linux Kernel Now Explicitly Uses GNU89, Not Yet C11 Friendly

    Phoronix: The Linux Kernel Now Explicitly Uses GNU89, Not Yet C11 Friendly

    While the Linux kernel is constantly improving, it cannot yet be built as C11 code...

    Phoronix, Linux Hardware Reviews, Linux hardware benchmarks, Linux server benchmarks, Linux benchmarking, Desktop Linux, Linux performance, Open Source graphics, Linux How To, Ubuntu benchmarks, Ubuntu hardware, Phoronix Test Suite

  • #2
    Why not rewrite Linux in C++(11)?
    Just using namespaces and structs with member functions alone would enhance readability significantly with absolutely no overhead.

    Comment


    • #3
      Originally posted by Grawp View Post
      Why not rewrite Linux in C++(11)?
      Just using namespaces and structs with member functions alone would enhance readability significantly with absolutely no overhead.
      Mostly because existing kernel developers prefer C. Another factor I see cited frequently is that the C++ ABI is defined more loosely than the C ABI.

      Comment


      • #4
        Originally posted by Grawp View Post
        Why not rewrite Linux in C++(11)?
        Just using namespaces and structs with member functions alone would enhance readability significantly with absolutely no overhead.
        Linus hates C++ and has no faith in the programming ability of C++ programmers.

        Comment


        • #5
          Originally posted by Grawp View Post
          Why not rewrite Linux in C++(11)?
          Just using namespaces and structs with member functions alone would enhance readability significantly with absolutely no overhead.
          Because that would take years to do, assuming the main kernel maintainers actually want to change the language.

          Comment


          • #6
            This sounds good to me. It was pretty awful there was a C (sub)standard assumption instead of being explicit. Now at least compiling will loudly and early fail if compiler does not support gnu89

            Comment


            • #7
              Originally posted by Grawp View Post
              Why not rewrite Linux in C++(11)?
              Just using namespaces and structs with member functions alone would enhance readability significantly with absolutely no overhead.
              not using c++ is a barrier for people who have no clue about systemprogramming or programming at all. the harder one insists on c++ the more likely it is that he should not contribute to the kernel

              Comment


              • #8
                Originally posted by Grawp View Post
                Why not rewrite Linux in C++(11)?
                Just using namespaces and structs with member functions alone would enhance readability significantly with absolutely no overhead.
                Have you taken the time to look at the kernel source before pressing the submit button?
                Hint: You can (easily) write *object oriented* code in C and the Linux kernel already does it.

                Oh and C++ code, especially when you start using operators, templates and multiple inheritance, is far less readable than C code as its nearly impossible to match the trashed assembly code with the actual C++ code.

                - Gilboa
                oVirt-HV1: Intel S2600C0, 2xE5-2658V2, 128GB, 8x2TB, 4x480GB SSD, GTX1080 (to-VM), Dell U3219Q, U2415, U2412M.
                oVirt-HV2: Intel S2400GP2, 2xE5-2448L, 120GB, 8x2TB, 4x480GB SSD, GTX730 (to-VM).
                oVirt-HV3: Gigabyte B85M-HD3, E3-1245V3, 32GB, 4x1TB, 2x480GB SSD, GTX980 (to-VM).
                Devel-2: Asus H110M-K, i5-6500, 16GB, 3x1TB + 128GB-SSD, F33.

                Comment


                • #9
                  Originally posted by pythoneer View Post
                  not using c++ is a barrier for people who have no clue about systemprogramming or programming at all. the harder one insists on c++ the more likely it is that he should not contribute to the kernel
                  Originally posted by gilboa View Post
                  Have you taken the time to look at the kernel source before pressing the submit button?
                  Hint: You can (easily) write *object oriented* code in C and the Linux kernel already does it.

                  Oh and C++ code, especially when you start using operators, templates and multiple inheritance, is far less readable than C code as its nearly impossible to match the trashed assembly code with the actual C++ code.

                  - Gilboa
                  Well, I've seen a small section of the Linux. I've ported the iMX233 SoC audio driver from 2.6.x kernel to 3.10+. I don't see how adding a little of syntactic sugar would hurt. Multiple inheritance has to be used with some care! but templates are just juicy macros with type checking and operators are ordinary functions with a little different syntax. Anyway I don't propose to utilize all features of C++ (and hell, I absolutely don't propose to use STL, that would be pure insanity.)

                  Just simple things ... why use fifo_add_function(fifo *f, thing) when one could use fifo_instance.add(thing)?
                  Why use prefixes like ieee80211_ when one could use namespaces?

                  I've actually debugged assembly generated from C++ few times. Most of the time it's not different from assembly generated from C. Member function symbols are nicely prefixed, templates have instance numbers. Anyway, how many times one debugs assembly beside when writing scheduler-dispatcher? And HW initialization functions are usually written directly in assembly.

                  Comment


                  • #10
                    I see no reason for remaking code in C++. I do see a reason to provide a C++ interface for drivers that wish to use C++. The way the codebase is now, it clearly was designed around ignoring the existence of C++. A lot of driver interfaces is really just a structure of function pointers. It's the definitions of the interfaces of other utilities from the Linux kernel that are a bother, most of which assume C++ isn't there. But really, if you make your own definitions, you could probably even pull off making a new driver in D if you really wanted to (and got the environment right). However, I'm not sure of any linker quirks or GCC quirks one should be aware of, so it may be more complicated than that.

                    EDIT: Inline functions and macros are also a problem. You'll have to recreate most of them and all of them if you aren't using a C* language.

                    Btw, C11 does allow for type-based macros using _Generic.
                    Last edited by computerquip; 17 November 2014, 08:46 AM.

                    Comment

                    Working...
                    X