linux - Print messages in kernel module using c++ -
I am editing a kernel module written in C ++ I want a function to print a message, but I think I can not use the I have tried to include When I compile with The Linux kernel does not support C ++ very well, and you can Whether it is C or C ++, you can finally print Note that the use of cout or any standard input / output stream library function because the module stays in the kernel space. iostream library:
.... #include G ++ :
Error: iostream: Any such file Or directory is not error: 'Cout' was not declared in this area & lt; Iostream & gt; - I suspect that none of the STLs are completely out of the question, but since I have seen in C ++ Linux kernel mode The standard implementation of cout and cerr are using OS features, which will definitely not work inside the kernel. So you should not use them, it would be possible to implement anything that works the same way (call it kostream ), and kostream & amp; Operator & lt; & Lt; (Kostream & os, sometype value) , which produces some output in the buffer, then use printk or some preferences that are printk To produce the actual output printk (or its components) to print things in the Linux kernel. Parts) can be used. fstream or stringstream is not also working inside the kernel.
Comments
Post a Comment