[Solved]getting cerr(stderr) to work

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
coolkehon
Posts: 355
Joined: Mon Oct 20, 2008 5:44 am

[Solved]getting cerr(stderr) to work

Post by coolkehon »

i want to get stderr to work how do i get it to work and also is there a way to tell the calling function of a funtions line number, file, etc for example

void function1()
{
tellErr();
}
void tellErr()
{
cerr << __CALLINGFUNCTION__ << endl;
}

the main point of this is to get cerr working just to make a note and then i want to get that second one working but order doesnt matter
Last edited by coolkehon on Thu Mar 05, 2009 6:04 am, edited 1 time in total.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Erm where do you want it to go exactly? If it is to the psp's screen then you would have to implement your own stream to handle it, if you want it to a file you should be able to reopen the C libraries stderr handle, if you want it to a terminal get psplink.

As for calling function info etc. I don't think you can on GCC, at least not in any sensible way.
coolkehon
Posts: 355
Joined: Mon Oct 20, 2008 5:44 am

Post by coolkehon »

what if i can get it to just goto a function and i handle it there and also how do i reopen std err because game wont start when i try to do it using sceKernelStderrInstall or when i try todo sceioreopen
coolkehon
Posts: 355
Joined: Mon Oct 20, 2008 5:44 am

Post by coolkehon »

if this question sounds dumb thats because it is but i dont know the answers and that doesnt make me dumb so can some just give me the answer i know its simple i just cant figure it out or find it for that matter
cosmito
Posts: 307
Joined: Sun Mar 04, 2007 4:26 am
Location: Portugal
Contact:

Post by cosmito »

How can you claim your question is dumb since you don't know the answer?
coolkehon
Posts: 355
Joined: Mon Oct 20, 2008 5:44 am

Post by coolkehon »

sometimes i'm dumb i search and couldnt find it and i know it has to be simple
Heimdall
Posts: 245
Joined: Thu Nov 10, 2005 1:29 am
Location: Netherlands
Contact:

Post by Heimdall »

On C (not C++) I've tried this and it works:

Code: Select all

/* freopen example&#58; redirecting stdout */
#include <stdio.h>

int main &#40;&#41;
&#123;
  freopen &#40;"stdout.txt","w",stdout&#41;;
  freopen &#40;"stderr.txt","w",stderr&#41;;
  printf &#40;"This sentence is redirected to a file."&#41;;
  fclose &#40;stdout&#41;;
  fclose &#40;stderr&#41;;
  return 0;
&#125;
I'd assume that it should work on C++ but I haven't tried it yet.
coolkehon
Posts: 355
Joined: Mon Oct 20, 2008 5:44 am

Post by coolkehon »

thank you very much that was so simple i tried sceKernelInstallStderr handler and that had to be kernel my app is user and i tried to do sceIoReopen which is also kernel but this works thanks man much obliged

edit: also cerr also prints to the same stream
Post Reply