Author Topic: Nspire I/O - Now with C++ support  (Read 10281 times)

0 Members and 1 Guest are viewing this topic.

Offline compu

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 275
  • Rating: +63/-3
    • View Profile
Nspire I/O - Now with C++ support
« on: November 19, 2013, 03:30:07 pm »
After ExtendeD added support for C++ to Ndless some months ago, I have added experimental C++ support to Nspire I/O now.
It has an iostream-like interface, so it should be easy to use (at least I hope it is :P )

The obligatory "Hello World":
Code: [Select]
#include <nspireio/console.hpp>

int main(void)
{
  nio::console c;
  c << "Hello World!" << nio::endl;

  return 0;
}

A more complete demo can be found here.
The output of that demo is attached below.

The source code can be found on Github and in the attached zip file (that contains the compiled library file and demos as well).

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Nspire I/O - Now with C++ support
« Reply #1 on: November 19, 2013, 04:19:02 pm »
Good to hear. :) I wonder if the PRIZM version has been cancelled or if it's still in development btw?

Offline ajorians

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 105
  • Rating: +47/-0
    • View Profile
Re: Nspire I/O - Now with C++ support
« Reply #2 on: November 19, 2013, 08:11:10 pm »
That is awesome!  I like Nspire I/O.  Thanks! :)

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Nspire I/O - Now with C++ support
« Reply #3 on: November 20, 2013, 12:12:21 am »
Good to hear. :) I wonder if the PRIZM version has been cancelled or if it's still in development btw?
I think I can call it an indefinite hiatus. I might pick it back up someday, but last time I tried, everything I compiled (NspireIO or not) crashed. Probably my installation of PrizmSDK. Anyway, I wonder if C++ support won't mess that up, since the Prizm have none of it...
« Last Edit: November 20, 2013, 12:12:35 am by Juju »

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Legimet

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +29/-0
    • View Profile
Re: Nspire I/O - Now with C++ support
« Reply #4 on: November 20, 2013, 08:42:24 am »
That's great to hear. Did you solve the inheritance issues that you posted about in another thread?

Offline compu

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 275
  • Rating: +63/-3
    • View Profile
Re: Nspire I/O - Now with C++ support
« Reply #5 on: November 20, 2013, 10:45:36 am »
Yup. I tried it with another approach without multiple inheritance and for now, everything seems to work more or less :P

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: Nspire I/O - Now with C++ support
« Reply #6 on: December 10, 2013, 05:11:48 am »
Nice Juju, that can make me go back to nSpire! :p

Offline Silversircel

  • LV0 Newcomer (Next: 5)
  • Posts: 4
  • Rating: +0/-0
    • View Profile
Re: Nspire I/O - Now with C++ support
« Reply #7 on: December 16, 2013, 05:09:18 pm »
Hi ,
every time i pass some variables to nspireio the programm crahes if i try to execute it.
I've no idea whats wrong.
I basicely only modified the exampel to display a cstring and a string. but it doesn't
work...
The programm crahes if i pass the variables with << operator.
Code: [Select]
#include <nspireio/console.hpp>
#include <nspireio/uart.hpp>
#include <string.h>
#include <string>
#include <iostream>

#ifndef NIO_TEST_UART
#define NIO_TEST_UART 0
#endif

using namespace std;
using namespace nio;

int main(void)
{
clrscr();
#if NIO_TEST_UART == 1
nio::uart u;
#endif
nio::console c;

int num = 123;
char cString[] = "Test";
string cppString = "Text";

c.foreground_color(COLOR_BLACK);
c << cString << endl;
c << cppString.c_str() << endl;

wait_key_pressed();
return 0;
}

Does anyone have a clue?
Thanks

Offline ajorians

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 105
  • Rating: +47/-0
    • View Profile
Re: Nspire I/O - Now with C++ support
« Reply #8 on: December 16, 2013, 07:23:05 pm »
Hi Silversircel,

There isn't a port of the Standard library for the calculator.  Here is a link to the syscalls: http://hackspire.unsads.com/wiki/index.php/Syscalls

I tend to use the char pointer (char*) and strcpy, strcat, etc.  Hope that helps!

Offline Legimet

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +29/-0
    • View Profile
Re: Nspire I/O - Now with C++ support
« Reply #9 on: December 16, 2013, 08:10:36 pm »
Silversircel doesn't use the C standard library in his/her program.

Also, there's newlib, and many of the functions in it work.
« Last Edit: December 16, 2013, 08:11:42 pm by Legimet »

Offline ajorians

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 105
  • Rating: +47/-0
    • View Profile
Re: Nspire I/O - Now with C++ support
« Reply #10 on: December 17, 2013, 09:05:55 am »
Hey Legimet,

Oh?  I see the user does all of these:
#include <string>
using namespace std;
string cppString = "Text";

As I understand newlib (https://sourceware.org/newlib/libc.html#Strings) it gives you a lot but this user is using the C++ string header file; and I think the C++ string class can throw exceptions and other things.  I didn't think the C++ std::string class would work at all.  But I'll give it a try when I get the chance! :)

Sorry if I wasn't accurate!  Have a great day!