Use libcxx for OS kernel development

Lately I started porting my hobby OS to C++. So far I've used C style error handling: function return value is interpreted as error code on failure. Unfortunately this is very inconvenient. One always has to look up the function documentation to figure out what values mean errors, etc. I think C++ exceptions are a superior mechanism. Unfortunately it's not so easy to get them working in kernel environment: http://wiki.osdev.org/C%2B%2B_Exception_Support.

Lately I have been learning Rust language. And it's error handling looks consistent and quite easy to use. One of the core classes is Result. Basically it's a simple enum which holds heterogeneous values: one for return value on success, other for error values. Sounds like something like this could be easily implemented in C++ too. Quick google search revealed me of already existing library: https://github.com/oktal/result.

oktal/result is a single file header only library. Thus it seemed like it would be easy to integrate into my kernel. The tricky thing is that it depends on couple of standard libraries:

#include <iostream>
#include <functional>
#include <type_traits>

Comments