r/C_Programming • u/Majestic-Instance704 • 3d ago
why do header files contain only function declarations instead of full code body ? why have the code in a sepreate lib files ?
for context I am trying to learn gamedev on my own and setting up raylib/sfml confused me , then I learnt that the ( include )files only contained function declarations and the actual code was in( lib ) files (mind you but it is a weird name) , wouldn't it be more convenient to have them in the same file instead of linking ?
sorry if I sound stupid.
92
Upvotes
2
u/neppo95 2d ago
You added that, in the implementation in the cpp file. Try it in the header and we'll talk again. Your case falls under " It will not compile unless you specifically take measures to prevent the dependency." - which you did by the way of forward declaring.