C++ operator new with parameters
Pages: 1 2
Bill Antonia (2466) 130 posts |
Glad to spark interest in C++ on RISCOS. I’ve been looking at I2C devices to drive motors, then recently to add polling, overloading the various Wimp events to send I2C messages to control the motors. Thought I would like to add window creation to my very limited C++ library. My very old PRMs show possible icon blocks at the end of the window definition, hence the need to possibly allocate space for them if I’m going to add this to my library as well, yes, the variable in the example code would be replaced by a window creation block. Most my coding for RISCOS in the past was in Pascal, C and Assembler on my RiscPC, but in between I’ve been been programming in Java. Now I’m retired I’ve got back to RISCOS, but on the Pi, hence the challange of OO on RISCOS. By the way, I did find a way, long ago, to unlock the time restriction on Acorns first version of Java they distributed FoC on CD. |
David J. Ruck (33) 1635 posts |
I really would caution against using the CFront C++ compiler from DDE, it is 35 years old and only supports a tiny fraction of even the most basic C++ features. You’ll be continually finding things which work everywhere else, just give strange errors. If you want to use C++ on RISC OS g++ is the only sensible option, particularly as it supports C++11 and later have a lot of useful new features (as opposed to the a lot of the stuff between CFront and C++11, which added horrendous complication). |
Chris Mahoney (1684) 2165 posts |
Hey, it’s only going to be 31 this year! Seriously, I was curious and looked it up. Cfront 3 was released in October 1991 (although Cfront 1 is from 1985). |
David J. Ruck (33) 1635 posts |
It is no different from the version of CFront (lack of feature for lack of feature) I learned C++ on in 1987 at UCL. The only improvement is I suspect it runs slightly faster on a Pi 4, than on a Sun 3/50 with networked storage and someone running Miranda from a remote green screen terminal at the same time. |
Chris Mahoney (1684) 2165 posts |
Yikes. I just peeked under the covers, as it were. Converting the Hello World sample app to C resulted in a 323-line file. |
Bill Antonia (2466) 130 posts |
Yes I know it is a very old compiler(translator) and has numerous limitations but I’m looking at this as a challenge/curiosity. Whatever I create is very unlikely to need to be portable. However, can g++ be used like in the DDE environment, with a front end? Without having to use command line? If so, what tool(s) would be needed on RISCOS? |
Jean-Michel BRUCK (3009) 359 posts |
RISC OS is a challenge, but I like it. I I’m also curious. For your second question, I find DDE very convenient and fast, I do a lot of testing. For curiosity, there is on the site riscos.fr a skeleton application in C++, compiled with the DDE and its source. “projdevbase”: https://jeanmichelb.riscos.fr/C++.html |
Rick Murray (539) 13840 posts |
No, it needs to be discarded. According to Wikipedia, the rest of the world ditched it in the early ‘90s when it became apparent that adding exception support was pretty much a non starter. |
Rick Murray (539) 13840 posts |
To expand on this, I believe the correct place for implementing C++ functionality is the compiler itself, not some sort of translator. |
Jeffrey Lee (213) 6048 posts |
To expand on this, I believe the correct place for implementing C++ functionality is the compiler itself, not some sort of translator. An Apache-licensed version of the sources to the C++ compiler from ARM SDT 2.11a was recently added to git: https://gitlab.riscosopen.org/RiscOS/Tools/Sources/ncc Presumably ROOL are planning on fixing it up and replacing CFront with it. Although since it dates from the mid-nineties it’s still going to be very outdated in terms of both C++ language support and CPU support. |
David J. Ruck (33) 1635 posts |
It’s simple to create a new DDE front end for any tool, it’s just a Desc file and a couple of sprites. But are you really using !C++ to compile? Any non trivial C/C++ program needs a makefile, and you can either create a standard one for GNU make (highly recommended), or if you must, an Acorn style one which can be run from the !AMU tool. |
Paolo Fabio Zaino (28) 1882 posts |
Yes. I have wrote my Front End file for it somewhere (I need to find it back), however, aren’t you using already a Makefile for your project? If so, no need for the Front End.
Indeed, but I don’t think there is a need for this anymore. We now have GCC 8 in the GCCSDK (and it can be compiled to run natively on RISC OS as well). GCC 8 produced a fairly good and optimised binary for the ARM CPUs that are being used by RISC OS. Yes, it defaults to ELF format, but that can be converted into AIF if one needs. GCC 8 supports all standards up to C++17 (and some C++20) which are considered the modern base for C++ (with the wildly adopted C++11). We can also build GCC 10 that covers more to C++20. Generally the exception handling is the weak point in GCC C++ for RISC OS, but that is something that people who wants to write fast C++ generally have to avoid using, unless being extremely careful. IMHO, the real missing tool on RISC OS is a good and reliable Desktop Debugger (possibly for both AIF and ELF and hopefully one day for modules as well). At the moment the best compromise is to use GDBServer and run a GDB session on a Linux machine, not so nice, but oh well. |
Paolo Fabio Zaino (28) 1882 posts |
Yup saw that, it’s encouraging actually, thought it might take a while before anything substantial will be available, but still a positive sign IMO :) |
Jean-Michel BRUCK (3009) 359 posts |
Hi all.
Very good news, Yes CFront is outdated and complicated to use in C++ |
Pages: 1 2