Re: libkern and standard c++ library
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meg.abyt.es; s=google; h=domainkey-signature:from:to:subject:date:user-agent:references :in-reply-to:reply-by:x-message:mime-version:content-type :content-transfer-encoding:message-id; bh=bkAMd6rif0pelAIeVSWO9mRw08384Pjky7J9dsOA4m8=; b=WkJGBOkBjYPPZoDxNOBLYOFDuIuyvygb2ibU5PbkXNDjB3NTJ+Wae2fnBjz/VU5LRz ELYA9cab8MYJv5MNXoPEN1/jJ6YwnmG3yoq6rCJ9zaUY8Ai980M0eDk2uYZgJzMx0skU jFwMrPxlu4dHz9qMVF4SjP8IjTDHTb5m4cnX0= Domainkey-signature: a=rsa-sha1; c=nofws; d=meg.abyt.es; s=google; h=from:to:subject:date:user-agent:references:in-reply-to:reply-by :x-message:mime-version:content-type:content-transfer-encoding :message-id; b=afrko3ZG1I3moqFPW+pxmgOzZbM6PcVBUyYbslj18acmFYq/0kk0YSq4RE3qz2iHCI OGW2LWvGp+qKQtAF8jnDm9zNws9WFLkGgczUH7s6VzUbFaMj/W+Prtzs+i1qRh7r7ckb rNT/EjQBK8m5CkugWEfBsr6qrwEFLzzNJaA8I= Reply-by: Wed, 19 Jan 2011 16:20:00 -0600 User-agent: KMail/1.13.5 (Linux/2.6.32-33-server; KDE/4.4.5; x86_64; ; ) 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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Tilghman Lesher