Basically as we all know Kernel code is compiled with gcc not and not having support for C++
This is an inaccurate statement. There is nothing to say that a C++ program cannot
include headers that are also used
in the compilation of the kernel.
However, what we are saying is that if you choose to take portions of particular files, as you have been doing, that not all
pieces are immediately transferable.
Point in case, if you took only part of the code you have highlighted:
And place this in your C++ code it may more than likely fail as C++ does not support this construct in this way,
hence why the reference to:
So now this particular set of code is portable to both C and C++
And I again what to say that I am learning internals of kernel and trying to find out why thing are done the way it is.
I approached the way to learn by directly looking into code itself.
And again I would say, you need to go and do a course (online or otherwise) as you have really asked very similar
questions about the exact same topic several times.