Shop OBEX P1 Docs P2 Docs Learn Events
GCC propeller C on linux — Parallax Forums

GCC propeller C on linux

I understand propware is a C++ library for the prop1 chip. I just want to use propeller C for programming. Is there any reason to not use propeller C than C++? I also had some difficulty installing Simple IDE so I figured I can try and use a different IDE.

Comments

  • That's a question that could quickly start a language war :lol:

    I like C++. Lots of others like C. Obviously, "lots of others" are wrong.

    That being said, PropWare's packages include the full suite of C libraries that Parallax maintains and distributes with SimpleIDE. You are not forced to use the PropWare C++ libraries in your code. But using the PropWare build system makes it easy to build and run your applications, and easy to link against the Simple Libraries outside of SimpleIDE (because Parallax do not provide static libraries nor a collection of headers for easy use in other build systems).
  • There is never a reason to use plain C where C++ is available. All C++ features are optional ("you don't pay for what you don't use"). The C++ frontend on crusty old GCC versions (such as propeller-gcc) also gives better error messages.
  • Wuerfel_21 wrote: »
    All C++ features are optional ("you don't pay for what you don't use"). The C++ frontend on crusty old GCC versions (such as propeller-gcc) also gives better error messages.

    I've not heard that before. Can you expand on what you mean by this? Do you mean "use g++ to compile .c files" or "Name all files with a C++ extension, even if you only use C syntax"?
  • DavidZemon wrote: »
    "Name all files with a C++ extension, even if you only use C syntax"?

    Yes, that. Mind you, there's some caveats. Notably, some C features aren't in C++. However, GCC tends to support them in C++ in some form, anyways, so all is well. (for example, C99's restrict keyword becomes __restrict__ in C++ and is a nonstandard extension).

    The main advantage of using C++ instead of C is that you're using C++ instead of C and can thus use C++ features like member functions, templates, etc to the extent you deem fit.

    The thing about the better error messages is hearsay, I haven't actually compared it myself, but I've heard it said a lot.

    Compiling *.cpp files through the "gcc" command won't link the STL by default, so if you want to use certain C++ features, you need to either manually specify it or put the bare essentials somewhere in the project:
    #include <cstdlib>
    void *operator new(unsigned int size) {
        return malloc(size);
    }
    void operator delete(void *ptr,unsigned int size) {
        free(ptr);
    }
    extern "C" void __cxa_pure_virtual(){
        puts("Purely virtual function call occurred!\n");
        exit(-42069);
    }
    

  • Wuerfel_21 wrote: »
    Compiling *.cpp files through the "gcc" command won't link the STL by default, so if you want to use certain C++ features, you need to either manually specify it or put the bare essentials somewhere in the project:
    #include <cstdlib>
    void *operator new(unsigned int size) {
        return malloc(size);
    }
    void operator delete(void *ptr,unsigned int size) {
        free(ptr);
    }
    extern "C" void __cxa_pure_virtual(){
        puts("Purely virtual function call occurred!\n");
        exit(-42069);
    }
    

    Which is exactly what PropWare's build system does for you :)
Sign In or Register to comment.