How to make iostream work

Asked by Marc Pignat

I'm trying to use iostream with the 4-7-2013q3 toolchain,
When I'm using printf and scanf, the redirection is done.
cin does nothing and cout does a hard fault.

Did I miss something?

Thank you in advance

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
Joey Ye
Solved:
Last query:
Last reply:
Revision history for this message
Joey Ye (jinyun-ye) said :
#1

Marc, Did you retarget _write and _read?

Thanks,
Joey

On Mon, Oct 28, 2013 at 6:21 PM, Marc Pignat <
<email address hidden>> wrote:

> New question #238197 on GCC ARM Embedded:
> https://answers.launchpad.net/gcc-arm-embedded/+question/238197
>
> I'm trying to use iostream with the 4-7-2013q3 toolchain,
> When I'm using printf and scanf, the redirection is done.
> cin does nothing and cout does a hard fault.
>
> Did I miss something?
>
> Thank you in advance
>
> --
> You received this question notification because you are an answer
> contact for GCC ARM Embedded.
>

Revision history for this message
Marc Pignat (swid) said :
#2

Sure, as said in the question, printf and scanf are working (and they use _read and _write).

Revision history for this message
Joey Ye (jinyun-ye) said :
#3

Em. We didn't test retarget for cin/cout. There might be issue in memory
consumption, which can be confirmed next week as I travelling now.

Joey
On Oct 29, 2013 9:21 AM, "Marc Pignat" <email address hidden>
wrote:

> Question #238197 on GCC ARM Embedded changed:
> https://answers.launchpad.net/gcc-arm-embedded/+question/238197
>
> Status: Answered => Open
>
> Marc Pignat is still having a problem:
> Sure, as said in the question, printf and scanf are working (and they
> use _read and _write).
>
> --
> You received this question notification because you are an answer
> contact for GCC ARM Embedded.
>

Revision history for this message
Marc Pignat (swid) said :
#4

Hello!

It seems that std::ios_base::Init() is never called.
Calling std::ios_base::Init() from main make cin and cout work.

Revision history for this message
Best Joey Ye (jinyun-ye) said :
#5

Did you call libc initialization function _start? If yes you won't need
that explicit call. If you jump to main directly all init for lib will be
skipped.
On Oct 30, 2013 2:06 AM, "Marc Pignat" <email address hidden>
wrote:

> Question #238197 on GCC ARM Embedded changed:
> https://answers.launchpad.net/gcc-arm-embedded/+question/238197
>
> Marc Pignat posted a new comment:
> Hello!
>
> It seems that std::ios_base::Init() is never called.
> Calling std::ios_base::Init() from main make cin and cout work.
>
> --
> You received this question notification because you are an answer
> contact for GCC ARM Embedded.
>

Revision history for this message
Marc Pignat (swid) said :
#6

Dear Joe,

I just spent the whole day finding the solution you just told me.
I learned a lot ;)

Thank you for you support.

Best regards

Marc

Revision history for this message
Marc Pignat (swid) said :
#7

Thanks Joey Ye, that solved my question.