3 ms·
You do not really to do that in C. If you are careful, the header only contains the visible interface, which is a list of functions that can be trivially deduc
by enriquto 8y ago
You do not really to do that in C. If you are careful, the header only contains the visible interface, which is a list of functions that can be trivially deduced from the non-static functions of the source file. Moreover, the header file is optional, and is never included by the source file.
In C++, yeah, this language sucks.
- dingo_bat 8y ago> Moreover, the header file is optional, and is never included by the source file. That is totally opposite to my experience. Example from Linux: https://github.com/torvalds/linux/blob/master/kernel/smpboot.c https://github.com/torvalds/linux/blob/master/kernel/smpboot... https://github.com/torvalds/linux/blob/master/kernel/smpboot.h https://github.com/torvalds/linux/blob/master/kernel/smpboot...
- frankzinger 8y agoYeah. If you don't include the header from the source file you will inevitably end up with differing function signatures in the header and source files because the compiler won't be able to compare the declaration and definition to each other. Such a program may even link.
- frankzinger 8y agoYou can do the exact same thing in C++: https://en.cppreference.com/w/cpp/language/pimpl https://en.cppreference.com/w/cpp/language/pimpl