开发者

C++ support in kernel module in 64-bit system

开发者 https://www.devze.com 2023-03-23 19:02 出处:网络
I know C++ is not recommended in kernel module, however, we have a module written in a mix of C and C++ files, the module works well i开发者_开发技巧n 32-bit system (kernel 2.6), now we are trying to

I know C++ is not recommended in kernel module, however, we have a module written in a mix of C and C++ files, the module works well i开发者_开发技巧n 32-bit system (kernel 2.6), now we are trying to port the module to 64-bit system, is C++ not supported at all in 64-bit system?


Roughly speaking, to use C++ in kernel, you should get rid of all C++ runtime library dependencies, first of all, you should reimplement new/delete and remove exception handling (compile with -fno-exceptions). Actually if the 32-bit code works, those simple cases must be already resolved.

Just try to compile and load the module. If you are lucky, there will be no linkage errors, and you have a good chance for a module to work (modulo the usual set of crossplatform issues such as structure sizes and alignment). If you are not, you will receive a list of undefined symbols that will give you a hint what should be implemented or worked around.


It's not a question of whether the language is supported on 64-bit, but whether the libraries and other code are portable.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号