c++ front-end

  • Jonathan

    Jonathan - 2006-04-22

    What interest is there in a c++ front-end
    to sdcc? For google's summer of code I'm
    considering submitting a proposal to extend
    sdcc to handle multiple languages.
    Right now I would plan on working on a c++
    front-end first and maybe others later.
    I've read the technical notes in in sdccman.pdf
    and looked through some of the source code of
    sdcc. Of the seven phases of the compiler I
    think this project would involve modifying
    and building parts the first phase and adding
    some features to the second phase.

    Is there anyone opposed to me doing this? Are
    there any developers who would be willing to be
    my mentor for this? Is a c++ front-end already
    being worked on?


    P.S. My Background:

    I'm an independent inventor attending school
    for a MBA. I have pending tehcnology patents
    such as a new kind of volumetric display. I
    have a undergraduate degree in computer
    enginneering with a minor in physics. I've used
    c++, c, and python for several years.

    • Anonymous - 2006-04-24

      Hi Jonathan,
      I'm just a user of SDCC (I have nothing to do with its development). This is my opinion on C++ in SDCC. Since C++ requires more code and data memory than standard C, its use would be quite limited. SDCC is for small devices. I am always glad to fit  the required sw in C+assembly into available hardware. I would most probably never start coding in C++ simply to avoid unnecessary danger of having to rewrite code to a more efficient C version later due to hw limits.

      I am not against C++ in general. My opinion is that C++ is for big processors, big memories and big software where "big" is appx. > 1MB.

      I would rather welcome some other improvements in the C compiler and linker. If you choose to work on C++ front end anyway, good luck.


      • riedel

        riedel - 2006-04-27

        This may and may not be true. C++ is just a programming language. The compiler is responsible for the performance of the generated code. Some features of the language might contribute to memory/runtime overhead, but you don't have to use them. However I doubt that sdcc has the neccessary optimizations to make "good" code from an OO language. It is not only front-end work neccessary.

        E.g. compare:

        or (only available in german):

    • Anonymous - 2006-05-03

      I didn't know about class flattening, so I read something about it (the pdf you link to and one paper which is literature [3] in the pdf). Thanks for the link. It seems to be an interesting approach to optimization. Maybe I should read more about it, but from what I understand up to now, class flattening is rather limited in what it can do. It is useful mainly in cases where class hierarchy and virtual functions are not necessary for functionality, only "nice" to use.

      In the article also noted that class flattening results in rather a lot of duplication of code. Since SDCC is for small devices, I believe that is a major drawback (for example, I am currently rewriting a major part of C code into assembly in my project because of lack of flash memory). Another little thing with classes is the "this" pointer, which actually adds an extra parameter to all functions -> stack or data memory usage increases.

      So, my opinion remains that SDC++C would probably not be worth the work. Even with class flattening directly built into the compiler.

      But thanks for the link.

    • AP2k

      AP2k - 2007-05-14

      The MCUs that SDCC compiles for arent powerful enough to easilly run C++ programs like x86 processors. Its not *impossible* to make a C++ compiler, but its a bad choice of language for many processors, even x86 in some cases.

      Besides, its not like you cant make C++ classes out of C structs. ;-)


Log in to post a comment.