babbleberry / rpi4-osdev

Tutorial: Writing a "bare metal" operating system for Raspberry Pi 4
https://www.rpi4os.com
Creative Commons Zero v1.0 Universal
3.37k stars 246 forks source link

A way to implement C++ #23

Closed 3c4ng1s closed 2 years ago

3c4ng1s commented 2 years ago

Hi, I’m not so sure if I’m doing this right and if my question is an issue at all, but just in case I’m leaving it here. I have read your code and I have enough knowledge to understand most part of it and actually get what is doing, but I would love to implement a kernel in cpp. Somehow I’m assuming at first that it will be connected to the compiler and compilation process, but I wouldn’t know how it should actually go.

babbleberry commented 2 years ago

Hi,

If you're using clang as your compiler, you simply use clang++ instead. Or if you're using gcc, use g++ instead.

Main changes (beyond the code) will be to the Makefile therefore, but the linking process should be the same.

I'd start simply and try to get part3 going in pure C++. I'm no C++ programmer, but I imagine the switch will be very easy. Circle is a good C++ OS/kernel that runs on the RPi - you might be able to take your cues from some of that too...

Thanks, Adam

babbleberry commented 2 years ago

Circle is here BTW: https://github.com/rsta2/circle

A

3c4ng1s commented 2 years ago

I read about Circle, but i’m searching a more direct implementation of C++ on bare metal levels… just for learning objective. The thing is that I want to use the class and object perspective of c++ instead of C. Even so, thank you for the help, of everything I have read you have given the most straight directions of all for newbies like me.

babbleberry commented 2 years ago

I wish you all the best for it :) You've made a great decision to go on this journey! I agree that C++ would ultimately end up in a tidier codebase... Maybe one day I'll give it a go!!