我想使用CFPropertyListWriteToStream
写信给stderr
。如果我输入stderr
作为参数,我会收到错误:
error: cannot convert ‘FILE*’ to ‘__CFWriteStream*’ for argument ‘2’ to ‘CFIndex CFPropertyListWriteToStream
如何创建一个写入CFWriteStream
的{{1}}对象?
答案 0 :(得分:1)
你可以使用我找到的技术here:
CFWriteStreamRef stdoutStream = NULL;
if (verbose) {
CFURLRef devStdout =
CFURLCreateWithFileSystemPath(NULL, CFSTR("/dev/stderr"),
kCFURLPOSIXPathStyle, false);
stdoutStream = CFWriteStreamCreateWithFile(NULL, devStdout);
if (stdoutStream == NULL)
errexit("cannot create CFWriteStream for /dev/stderr");
if (!CFWriteStreamOpen(stdoutStream))
errexit("cannot open CFWriteStream for /dev/stderr");
}