• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: stdout redirect in xcode and not
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stdout redirect in xcode and not


  • Subject: Re: stdout redirect in xcode and not
  • From: "Wesley Smith" <email@hidden>
  • Date: Mon, 22 Dec 2008 12:39:26 -0800

>        Do you possibly call the code you have written to install this
> handler from an
> assert macro?
>        Such code gets stripped in release builds.


Good to know, but this is not what's happening here.  I'm calling it
from within a Cocoa method:

- (void)startRedirect
{
	if (!oldWriteFunc)
	{
		oldWriteFunc = stream->_write;
		stream->_write = stream == stdout ? stdoutwrite : stderrwrite;
	}
}

Full code can be found here:
https://svn.mat.ucsb.edu/projects/luaAV/browser/branches/mergathon/LuaAV/library/osx/LuaAVLog.m

What's interesting is that in other bits of code within my project,
I've tried printing out the address of stdout->_write and it's exactly
the address of my stdoutwrite handler function.  For whatever reason,
std::cout, printf and fputs are not respecting stdout->_write when the
app is launched from Finder.  This begs 2 questions

1) Why is this so?
2) What is the proper way to redirect stdout from within a Cocoa app?

So far I've found no example code online.  Any pointers would be great.
thanks,
wes
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: stdout redirect in xcode and not
      • From: Jason Foreman <email@hidden>
References: 
 >stdout redirect in xcode and not (From: "Wesley Smith" <email@hidden>)
 >Re: stdout redirect in xcode and not (From: Tommy Nordgren <email@hidden>)

  • Prev by Date: How do I link with copied libs?
  • Next by Date: Re: stdout redirect in xcode and not
  • Previous by thread: Re: stdout redirect in xcode and not
  • Next by thread: Re: stdout redirect in xcode and not
  • Index(es):
    • Date
    • Thread