c++ in linux kernel

By: gallier2 (gallier2.delete@this.gmx.de),
Room: Moderated Discussions
Michael S (already5chosen@yahoo.com) on 6/7/10 wrote:
---------------------------
>gallier2 (gallier2@gmx.de) on 6/7/10 wrote:
>---------------------------
>>Michael S (already5chosen@yahoo.com) on 6/7/10 wrote:
>>---------------------------
>>>gallier2 (gallier2@gmx.de) on 6/7/10 wrote:
>>>---------------------------
>>>>? (0xe2.0x9a.0x9b@gmail.com) on 6/6/10 wrote:
>>>>---------------------------
>>>>>
>>>>>Another example: Let there be static functions FN1 and FN2 which are defined in
>>>>>a single file. Imagine a circular dependency between FN1 and FN2. Imagine the file
>>>>>got bigger and it is painful to maintain it. So, you are thinking about splitting
>>>>>the 1 file into 2 smaller files, placing FN1 and FILE1 and FN2 in FILE2. But, you
>>>>>don't want to expose the functions FN1 and FN2 to the outside world - you want to
>>>>>keep then hidden and be accessible only from the "module" that comprises from files
>>>>>FILE1 and FILE2. Can this be done in C? No, it can not. Imagine another language
>>>>>that is capable of expressing this idea - would you call the language feature that
>>>>>allows you to express this a "syntactic sugar"?
>>>>>
>>>>Easy, split your file as C files and include the .c files directly, it's not very
>>>>common but absolutely allowed and relativly easy to handle.
>>>
>>>It still puts the names in question into global name space. If names are too simple,
>>>project is huge and has no single Czar your solution is asking for trouble.
>>
>>Only for non static names. The statics are only visible inside the compilation unit.
>>The interface of extern objects does not have to change.
>>
>>> Prefix,
>>>as suggested by Linux, is much safer, but also more intrusive and makes textual comparison with old versions harder.
>>>
>>
>
>Sorry, I jumped to posting without really reading you suggestion :embarrassed:
>By now, except from being non-idiomatic and, as such, non-compliant with the principle
>of least surprise you solution should work just fine.

You're right and I wouldn't advocate the use of that solution. In the project I manage (about 200000 lines of C and Pro*C) there is 1 module (dynamic library) where I would need the feature of a third level of visibility besides the global and compilation unit one (a module visibility so to say) as it was built from the splitting of 1 huge Pro*C file. But even in this case I would not use my suggestion above.

> But back in the early 90s
>when namespaces we originally added to C++ language, separate compilation was still
>considered important even at scale of 2-3 modules.
>

In my view, it's more a linker and optimisation problem than anything else, especially with dynamic libraries. Name collisions are relatively rare with some discipline and not really difficult to resolve when encountered.
< Previous Post in ThreadNext Post in Thread >
Thread (207 posts)
TopicPosted ByPosted
c++ in linux kernelnewbie
  c++ in linux kernelrwessel
    c++ in linux kernelslacker
      Forums and C/C++David Kanter
        Forums : flat vs. threaded.Dean Kent
          Forums : flat vs. threaded.anonymous
            Forums : flat vs. threaded.Rob Thorpe
              Forums : flat vs. threaded.Dean Kent
      c++ in linux kernelnewbie
        c++ in linux kernelnksingh
        c++ in linux kernelDavid Kanter
        c++ in linux kernelHeath Provost
          c++ in linux kernelLinus Torvalds
            c++ in linux kernel?
              c++ in linux kernelnksingh
                c++ in linux kernelS. Rao
              c++ in linux kernelmpx
                c++ in linux kernelEduardoS
              c++ in linux kernelLinus Torvalds
                c++ in linux kernelMichael S
                c++ in linux kernel?
                  c++ in linux kernelPekka Enberg
                    c++ in linux kernelMichael S
                      c++ in linux kernelPekka Enberg
                        c++ in linux kernelMichael S
                          c++ in linux kernelPekka Enberg
                    c++ in linux kernelVincent Diepeveen
                      c++ in linux kernel?
                  c++ in linux kernelnemlis
                c++ in linux kernelMark Christiansen
                c++ in linux kernelNeo
                  Poor troll, try harder next time (NT)Matt Sayler
                  c++ in linux kernelRohit
              c++ in linux kernelgallier2
                c++ in linux kernelMichael S
                  c++ in linux kernelgallier2
                    c++ in linux kernelMichael S
                      c++ in linux kernelgallier2
                c++ in linux kernel?
                  c++ in linux kernelMichael S
                    c++ in linux kernel?
                      c++ in linux kernelMichael S
                        c++ in linux kernel?
                          c++ in linux kernelMichael S
                  c++ in linux kernelEduardoS
              c++ in linux kernelCodeGrunt
            c++ in linux kernelnewbie
            c++0x any better?Max
              c++0x any better?anon
                c++0x any better?Michael S
            c++ in linux kernelLispLover
              c++ in linux kernelRob Thorpe
            c++ in linux kernel - more disadvantagesVincent Diepeveen
            c++ in linux kernelsomeone
            c++ in linux kernelJohn Regehr
            c++/java in linux kerneliirekm
              c++/java in linux kernelanon
                c++/java in linux kerneliirekm
                  c++/java in linux kernelRob Thorpe
                  Java is not just syntactic sugar on top of assemblyMark Roulo
                    no it is :-)iirekm
                      no it is :-)Mark Roulo
                        no it is :-)iirekm
                          no it is :-)Gabriele Svelto
                  c++/java in linux kernelanon
                c++/java in linux kernel?
                  c++/java in linux kernelEduardoS
                  c++/java in linux kernelanon
                    C is more portable than assembly??
                      C is more portable than assembly?anon
                        C is more portable than assembly??
                          C is more portable than assembly?anon
            c++ in linux kernelBob
        c++ in linux kernelAaron Spink
          c++ in linux kernelRichard Cownie
            c++ in linux kernelanon
              c++ in linux kernelRichard Cownie
                c++ in linux kernelAaron Spink
                  c++ in linux kernelRichard Cownie
                    c++ in linux kernelMark Roulo
                      very interesting case study, thanks (NT)Richard Cownie
                      Okay, wait, let me get that straightTimmy
                        Split codebase..Anon
                        Okay, wait, let me get that straightRichard Cownie
                          Okay, wait, let me get that straightanonymous
                            Okay, wait, let me get that straightMax
                            Okay, wait, let me get that straightGabriele Svelto
                              Okay, wait, let me get that straighthobold
                                Okay, wait, let me get that straightSalvatore De Dominicis
                            Okay, wait, let me get that straightRichard Cownie
                            Okay, wait, let me get that straightMark Roulo
                              Okay, wait, let me get that straightRob Thorpe
                        Okay, wait, let me get that straightMark Roulo
                        Okay, wait, let me get that straightEduardoS
                c++ in linux kernelanon
            Joke: C programs are high-performance?
              Programmers Need To Learn Statistics Or I Will Kill Them Allanon
                Programmers Need To Learn Statistics Or I Will Kill Them All?
                  Programmers Need To Learn Statistics Or I Will Kill Them Allhobold
                  Programmers Need To Learn Statistics Or I Will Kill Them AllMark Roulo
                    Programmers Need To Learn Statistics Or I Will Kill Them All?
                      Programmers Need To Learn Statistics Or I Will Kill Them AllMark Roulo
                To kill programmers just ship them to Tomtom - Gestapo methods there (NT)Vincent Diepeveen
            c++ productivityanon2
              c++ productivityLinus Torvalds
                c++ productivityRob Thorpe
                c++ productivityD.P.
                  c++ productivityLinus Torvalds
                    c++ productivityanon2
                      c++ productivityMark Roulo
                        C with pointer checkingMax
                          C with pointer checkingD.P.
                            C with pointer checkingMax
                              C with pointer checkingD.P.
                        DIE FORTRAN, DIERohit
                          DIE FORTRAN, DIEa reader
                            DIE FORTRAN, DIEhobel
                            DIE FORTRAN, DIED.P.
                      c++ productivityD.P.
                    c++ productivityMaxthon T. Chan
                c++ productivityWalter Bright
                  c++ productivityD.P.
                    c++ productivityNick Sabalausky
                      c++ productivityD.P.
                        c++ productivityWalter Bright
                          c++ productivityD.P.
                            c++ productivityJesse Phillips
                            c++ productivityWalter Bright
                              c++ productivityD.P.
                                c++ productivityNick Sabalausky
                                c++ productivityWalter Bright
                                  c++ productivityD.P.
                            c++ productivityNick Sabalausky
                Context-dependency considered harmful??
                c++ productivityAlok
                  c++ productivityLinus Torvalds
                    c++ productivityanon
                    c++ productivityEva
                    c++ productivityOh Come On Dept
                      c++ productivityLinus Torvalds
                        c++ productivityMark Christiansen
                          c++ productivityLinus Torvalds
                            c++ productivitystubar
                            c++ productivitya reader
                              c++ productivityGabriele Svelto
                                c++ productivityBrad Cantrell
                            c++ productivity?
                              c++ productivityJouni Osmala
                                c++ productivityEduardoS
                            c++ productivityTimmy
                              c++ productivityEduardoS
                                c++ productivityrwessel
                                  c++ productivityEduardoS
                                    c++ productivityrwessel
                                      c++ productivityAnon
                                        c++ productivityMark Roulo
                                          c++ productivityEduardoS
                                            c++ productivityMark Roulo
                                        c++ productivityrwessel
                                          c++ productivityAnon
                                            c++ productivityrwessel
                                              c++ productivityhobel
                                                c++ productivityrwessel
                                                  c++ productivityRob Thorpe
                                                    c++ productivityhobel
                                              c++ productivityMichael S
                                                c++ productivityrwessel
                                                  c++ productivityMichael S
                                                    c++ productivityrwessel
                                                      c++ productivityMichael S
                                                        c++ productivityrwessel
                                              c++ productivity - apologyrwessel
                                              c++ productivityRob Thorpe
                                                c++ productivityMark Roulo
                                                  c++ productivityRob Thorpe
                                              c++ productivityAnon
                                c++ productivityanonymous
                            c++ productivitytm
                              c++ productivitygallier2
                        c++ productivityOh Come On Dept
                c++ productivityKagamin
                  c++ productivityanon
                    c++ productivityDavid Kanter
                      c++ productivityRichard Cownie
                        c++ productivityCharles
                          c++ productivityRichard Cownie
                          well-designed C++ librariesD.P.
                            boost sucksanon
                              what c++ libraries does not suck?D.P.
                                amount of ignorance to history?
                                  amount of ignorance to historyCharles
                                    amount of ignorance to historyanon
                                      amount of ignorance to historyMark Christiansen
                                        amount of ignorance to historyanon
                                    Boost is being used to illustrate that good C++ is unreadable by mostMark Roulo
                                    amount of ignorance to historyD.P.
                            well-designed C++ librariesanon
                              well-designed C++ librariesD.P.
                                well-designed C++ librariesanon
                                  well-designed C++ librariesD.P.
                                well-designed C++ librariesKagamin
                                  Lack of features can be a featureDavid Kanter
                                  some features have global effectsRichard Cownie
                                    some features have global effectsTimmy
                      c++ productivityRob Thorpe
                      c++ productivityKagamin
                c++ productivityfast