Results 1 to 7 of 7

Thread: Question about C++ feature (cout)

  1. #1

    Default Question about C++ feature (cout)

    Hi, currently I test some C++ features.
    I use the SimpleIDE Version 0.6.2. and have this code snippet

    Code:
     #include <vector>
     #include <string>
     #include <iostream>
      using namespace std;
    
    int main(void)
     {
         vector<unsigned char>v;     // ok
         v.push_back(0xAA);              // ok
          string s = "Hello";                  // ok
         cout << s << endl;              // Build failed here
          return 0;
     }
    Get this build result
    Code:
    knoppix@Microknoppix:~/myC/propeller_chip/_propgcc/cpp_vector_test$ propeller-elf-c++ -o a.out -Os -mxmmc cpp_vector_test.c -s
    /home/knoppix/propgcc/bin/../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/lib/xmmc/libstdc++.a(basic_file.o): In function `.LVL34':
    /home/steve/gcc/build/gcc/propeller-elf/xmmc/libstdc++-v3/src/basic_file.cc:219: undefined reference to `_fdopen'
    collect2: ld returned 1 exit status
    Can not copy the message from the Build Status window, so I reproduce it on command line, thats no diff.

    Is it not planned to use cout on C or do I something wrong or is it a bug ?

    regards
    Reinhard

  2. #2

    Default Re: Question about C++ feature (cout)

    I suspect that cout and the streams "<<" require further library support (libstdc++) and that that library is huge, to big to think about fitting in the Prop.
    It is hard enough getting printf and co. in there.

  3. #3

    Default Re: Question about C++ feature (cout)

    Yes, I see libstdc++ is a huge library and not needed for Cs like prop.But other objects like vectors can be used from STL, and this is a big advantage. (in xmm / xmmc models)

  4. #4

    Default Re: Question about C++ feature (cout)

    Quote Originally Posted by Reinhard View Post
    Hi, currently I test some C++ features.
    Is it not planned to use cout on C or do I something wrong or is it a bug ?
    Reinhard,

    cout is supported in XMM/XMMC modes, so it's a bug. Feel free to file an issue on the PropGCC development website at http://code.google.com/p/propgcc/issues/list.

    In the interim, you can work around this by including the following snippet of code somewhere (anywhere) in your program:

    Code:
    #include <stdio.h>
    extern "C"
    {
      FILE* fdopen(int fd, const char* mode) { printf("Ooops, if we got here there's trouble afoot\n"); }
    }
    Note that I haven't analyzed what that particular call to fdopen does (I believe the file in question is actually gcc/libstdc++-v3/config/io/basic_file_stdio.cc in the PropGCC source), but I know you don't need it for simple cout operations. With the above work-around, if you do something thta needs it, you'll get the "Ooops" error on your console.

    Also note that adding iostream to a program adds around 500K, this it takes your 100K program and blows it up to over 600K! This takes almost a full minute to upload to a C3.

    There is a "tiny" library posted on another thread at http://forums.parallax.com/showthrea...erial-terminal; this would reduce your memory footprint greatly if you just want to print simple objects using cout (and not generic file I/O to memory, other devices, etc.).

    Note, however, that the library was designed for LMM mode and I never tested it in XMM modes. Your issue caused me to finally test it; it appears there are some bugs and it doesn't work in XMM mode - I'll try to get to these soon. Watch the forum for updates.

    - Ted
    Last edited by denominator; 04-23-2012 at 12:22 AM. Reason: Typo: LMM -> XMM/XMMC

  5. #5

    Default Re: Question about C++ feature (cout)

    Eric pushed a fix for the fdopen dependency. Thanks Eric.

    A simple hello c++ cout program will work with board type C3 and -mxmm or -mxmm-split mode.
    Unfortunately, -mxmmc model does not have enough data space in Propeller HUB RAM to run using cout.

    Applications using the standard c++ library without cout and iostreams will run with -mxmmc programs.
    You will need to use printf or some other console IO alternative of course.

    I'll get some packages out soon. For binary users. Source builders can update and build now.

    Thanks,
    --Steve

  6. #6

    Default Re: Question about C++ feature (cout)

    Thank's to all be involved.I'll assert that if this issue run on C3, the propgcc (and the propeller) is in a liga like ARM.best regards,Reinhard

  7. #7

    Default Re: Question about C++ feature (cout)

    Quote Originally Posted by Reinhard View Post
    Thank's to all be involved.I'll assert that if this issue run on C3, the propgcc (and the propeller) is in a liga like ARM.best regards,Reinhard
    Great! Hopefully we'll be able to add another ARM-like feature later

Similar Threads

  1. BST feature
    By MacGeek117 in forum Propeller 1 Multicore Microcontroller
    Replies: 2
    Last Post: 07-02-2010, 01:10 AM
  2. Search feature question
    By Thomas Taylor in forum Support for Using this Forum
    Replies: 3
    Last Post: 11-24-2005, 01:53 AM
  3. Bug or feature?
    By Tommi in forum Support for Using this Forum
    Replies: 2
    Last Post: 12-22-2004, 11:21 AM
  4. clock feature
    By Archiver in forum BASIC Stamps Archive
    Replies: 3
    Last Post: 05-24-2004, 05:12 AM
  5. Cout of super carrier board voltage regulator
    By Archiver in forum BASIC Stamps Archive
    Replies: 3
    Last Post: 02-14-2003, 02:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts