Re: libkern and standard c++ library
Re: libkern and standard c++ library
- Subject: Re: libkern and standard c++ library
- From: Tilghman Lesher <email@hidden>
- Date: Thu, 23 Jun 2011 01:16:03 -0500
- Reply-by: Wed, 19 Jan 2011 16:20:00 -0600
On Wednesday 22 June 2011 14:08:31 Abhinav Tyagi wrote:
> Is it possible to use <iostream> library and stdio.h with libkern.
> stdio.h seems to conflict with the printf() function because of
> multiple definition when used with the libkern.
No, it's not. The problem is that you're not in userspace, which is where
these library routines are located; you're in kernelspace, and you have a
very limited number of routines available to you.
> I need to write data to a file for debugging purpose and am not able to
> use standard library <fstream> or stdio.h routines. If these are not
> allowed please suggext me the method how can i write to files while
> working with libkern.
The best thing for you to do is to use the IOLog() function within IOKit
and rely on the syslog interface to do the actual logging to a file. While
it's conceivably possible to write directly to a file in kernelspace, it's a
really bad idea. If you're needing to load a configuration file, run a
userspace program at load time to do the parsing and pass the values in via
a named device, typically with the ioctl(2) kernel call.
If you want more information, I'd strongly recommend getting yourself a
textbook on kernel internals, such as "Design and Implementation of the
4.4 BSD Operating System" by McKusick et al. While it doesn't directly
address Darwin internals, it's an excellent guide to understanding kernel
programming in general, and in particular, why there are certain things
you never want to do directly from kernelspace.
--
Tilghman
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden