Moving the kernel to modern C
Moving the kernel to modern C
Posted Mar 4, 2022 17:28 UTC (Fri) by marcH (subscriber, #57642)In reply to: Moving the kernel to modern C by dvdeug
Parent article: Moving the kernel to modern C
??
The type of the variable does not provide vtable resolution. That's done only at run-time. Same problem for explicit .ops function pointers in C. You cannot just "grep" through vtables / .ops because they're resolved at run-time. That's the whole OO proposition.
> Assuming you're not using Ruby, the type of the variable should be named nearby in the code.
Afraid you lost me there.
> In C, the definition of the function may be found in one of the files you #included in this code (or not; you can always declare external functions directly), but that header file name may have no relation to the file where the code is written.
Code indexers can do a surprisingly good job most of the time. For the rest there is always git grep. It works as long as nothing is resolved at run-time.
> Of course, with the handy -D option to the C compiler, who knows what the function is actually named.
I've seen many -D and I've never seen one redefining function names. As already wrote above, no one like the pre-processor and its abuse is very easily and routinely caught at code review. The entire problem with C++ is "where do you draw the line?". That's really not a problem with the pre-processor: it's always very obvious whether you use it or not and I've seen "no pre-processor here" review comments countless times.
Posted Mar 4, 2022 20:22 UTC (Fri)
by marcH (subscriber, #57642)
[Link]
Same trick with build systems and many other situations with "too many layers of indirections": deliberately injecting errors is often a great shortcut.
(none of that available at run-time of course)
Posted Mar 5, 2022 2:42 UTC (Sat)
by dvdeug (guest, #10998)
[Link]
That's a problem with C++, not operator overloading or object orientation.
> That's really not a problem with the pre-processor: it's always very obvious whether you use it or not and I've seen "no pre-processor here" review comments countless times.
It is quite similar to operator overloading; you can see where the macro or operator is defined, but not necessarily where it is used.
Moving the kernel to modern C
Moving the kernel to modern C
