As the title says, what are they and what’s the difference?
Some examples:
dmain:
void dmain(void* mbd, unsigned int magic)
kmain:
void kmain( void* mbd, unsigned int magic )
P.S. I found a similar post here but it was about wmain:
What is the difference between wmain and main?
Also _tmain:
What is the difference between _tmain() and main() in C++?
__
They take the same arguments but is there a difference? And any links to some info this so I could learn is appreciated, google yielded weird results…
Also, is there an official sort of like ‘man’ pages of C?
You seem to be referring to this tutorial on OSDev.org.
If you’ll notice, this is not a standard C program with
main()as its entry point. In fact, the page shows two entry points: one written in Assembler in a way for GRUB to find & load, and which sets up & loads the second,kmain(), which is written in C. The writers use the namekmainto mean “kernel main”; presumablydmainis the entry point for drivers & would stand for “driver main”.C makes a distinction between “freestanding” and “hosted” implementations. Hosted is what you’re probably more familiar with; the standard C library is available, and all programs start at the
mainfunction.OS kernels are (often) good examples of freestanding environments. The C library will likely not be available, for example (except for certain headers like
stddef.h&stdarg.h; see the standard for details). Also, the entry point is not defined by the standard anymore. The OSDev.org tutorial is making a special point of that fact, by explicitly defining its entry point with a different name.You could probably run the tutorial renaming
kmaintomain, but note that it’s stillvoid main(void*, unsigned int), notint main(int, char**); in fact that sort of confusion is likely part of the reason the writers chose to use a different name. But is is just a convention they’ve selected, not anything standardized.