What about C++?
I was using a C++ tutorial to work PropGCC, and failure right from the start.
-> Error on iostream.h
-> Error on Using namespace std
-> Error on cout
It seems like the code below is the standard example for working with C++, so I guess some people might be a little disappointed to see the errors. Now, the question is, what exactly can you do in PropGCC C++? This is not a criticism, just trying to find out what exactly can be done in C++, that would look like C++? I looked in the wiki but did not find anything for the use of C++.
I have seen talk about using objects in C++, so I thought I would look into that to see how it would be of any benefit with the use of the Propeller. The concept of C++ Objects sounds interesting, just might be a good tool to manipulate the Propeller. Anybody have any ideas on this?
Ray
-> Error on iostream.h
-> Error on Using namespace std
-> Error on cout
It seems like the code below is the standard example for working with C++, so I guess some people might be a little disappointed to see the errors. Now, the question is, what exactly can you do in PropGCC C++? This is not a criticism, just trying to find out what exactly can be done in C++, that would look like C++? I looked in the wiki but did not find anything for the use of C++.
I have seen talk about using objects in C++, so I thought I would look into that to see how it would be of any benefit with the use of the Propeller. The concept of C++ Objects sounds interesting, just might be a good tool to manipulate the Propeller. Anybody have any ideas on this?
Ray
/**
* @file test1.cpp
* This is the main test1 program start point.
*/
//#include <iostream.h> // This shows up as an error
//using namespace std; // This shows up as an error
/**
* Main program function.
*/
int main(void)
{
cout << "Hello, World!"; // Does not know what cout is
return 0;
}

Comments
Consider the objects of Spin. You can create similar object based prgrams in C++. In fact there is Spin to C++ translator, discussed on this forum that does exactly that.
Now, be aware that some common C++ usage may not be suitable for a memory constrained MCU. For example that hello world program uses stream I/O to output the message.
Streams require big string libraries and dynamic memory allocation. Perhaps too big to fit in memory. So I would not be surprised if the library support for streams was not included in the package at all. Hence the error.
Your example is not valid. It should be:
#include <iostream> using namespace std; int main(void) { cout << "hello"; return 0; }C++ objects like iostream are not included as .h files.
While it is possible to use standard name space libraries on Propeller, it is not practical.
Many other C++ features are practical and beneficial.
Ray
The other thing that I tried was to comment out: using namespace std;, this has a direct effect on the cout command, meaning it was not available. Now I have to figure out how to get something to appear on the console screen.
Ray
/** * @file test1.cpp * This is the main test1 program start point. */ #include <iostream> #include <propeller.h> #define NEWLINE '\n' using namespace std; /** * Main program function. */ int main(void) { waitcnt(CLKFREQ/10+CNT); // cout << NEWLINE << "Hello, World!" << NEWLINE << NEWLINE; cout << "hello\n"; return 0; }Using cout will bring in a 520KB library. Don't bother.
I believe you mentioned that Tues you will have some kind of preview? I take it this concerns SimpleIDE? Any advance info that you can present at this time, especially as it concerns C++, or PopGCC for that matter?
Ray
There are very few changes in SimpleIDE - the wish-list for that is being considered separately.
Seems like a big problem for C++ if the library that allows cin and cout >32kB...
I still want to pursue the use of cout command. I have switched over to the DNA board, so I can use the flash ram more, and to see how much faster the loading goes. Much faster, are my first indications. The program below compiles, but I get an "error: Loading program image failed". I also see:
9528 bytes sent
Verifying RAM ... Loading cache driver 'winbond_sqi_flash_cache.dat'
1732 bytes sent
error: Loading program image failed
My board settings:
DNA:SQI
C++
XMMC
-Os Size
I tried both the XMMC, and XMM-Single Memory Model, both came up with - "error: Loading program image failed". I also get the same error with the QuickStart board. So, I am not sure where the problem is on this one. Sure would like to see something appear on the console screen.
Ray
/** * @file test2.cpp * This is the main test2 program start point. */ #include <iostream> #include <propeller.h> using namespace std; /** * Main program function. */ int main(void) { int n = 1; while(1) { waitcnt(CLKFREQ/10+CNT); cout << "Hello" << n; n++; } return 0; }Not really, you don't have to be using all the features of a language and it's standard libraries. People use C on MCU's (PIC's, AVR's etc) with tiny memory spaces, they just don't expect to be using printf or whatever else does not fit. We can use C to good effect to create in COG code where such thing for sure do not fit. The Arduino uses C++ with similar limitations to those Jazzed has described.
What? Have I missed something? Are you saying someone is working on a CMM target for GCC similar to Catalina's?
Gosh - where have you guys been? CMM is sooo yesterday!
Ray
Wow, that Eric is a dynamo, amazing. I'll try and find time to check it out.
Sounds like it might get interesting mixing C compiled into native COG PASM with a project in CMM.
RossH,
He he, All good ideas are worth, err.. borrowing, and you have some of the best:)
The post picture below from the private forum references a post from Eric on Jan 24, 2012.
Which was followed by this: http://forums.parallax.com/showthread.php?140896-C-Spin-benchmarks&p=1106669&viewfull=1#post1106669
You get credit for making it a higher priority and showing the value of it. Thanks for your service.
--Steve
The CMM really is a game changer for C on Prop 1. Probably irrelevant for Prop 2, I imagine.
BTW: I wonder if Parallax would ever consider a special run of Prop 1 chips with the spin interpreter replaced by CMM C interpreter...
Would it work?
Indeed.
That's part of what I meant by "and showing the value of it." That was my edit after giving the post more thought.
Why? The Prop II RAM is bigger but it's still tiny.
A Prop I with a CMM interpretter sounds briliant. Can such an interpreter fit in a COG like the Spin interpretter does?
Words fail me ...
Now now, the pair of you. You should be ashamed. The idea of a compressed code as a target for C compilation on the Prop dates from early 2010. Ever heard of Zog:)http://forums.parallax.com/showthread.php?119711-Zog-A-ZPU-processor-core-for-the-Prop-GNU-C-C-and-FORTRAN.Now-replaces-S
Anyway, my hat off to Ross, Jazzed, Eric and all involved in bringings C to the Propeller world, especially in such inovative ways. You guys have been moving mountains to get C to play well on the Prop, where others may have dismissed it as "not a suitable architecture for C", myself included.
C:/propgcc/bin/propeller-elf-gcc.exe
C:/propgcc/propeller-load/
E:/PropGCC_SimpleIDE/PropGCC/test1/test3/
Ray
/** * @file test3.cpp * This is the main test3 program start point. */ #include <tinyiostream> #include <propeller.h> using namespace std; /** * Main program function. */ int main(void) { waitcnt(CLKFREQ/6+CNT); cout << "Hello World!"; return 0; }Ray
/** * @file test3.cpp * This is the main test3 program start point. */ #include <tinystream> #include <propeller.h> using namespace std; /** * Main program function. */ int main(void) { waitcnt(CLKFREQ/6+CNT); cout << "Hello World!"; return 0; }