Jump to content

Multifile c programs and placing of comments


Recommended Posts

So for some reason we we're never introduced to the concept of using multiple files and using make in our c programming module. I've no idea why.

 

I'm sure i can work out the details with the header files and how to produce a makefile, but i was wondering about best practices regarding commenting. I usually like to place a comment along with most functions to describe it's purpose and give a parameter list and return value. However, i'm wondering whether or not most people would expect to find this information in the header files or the source files?

 

Seems kind-of logical to place it along with the function prototype in the header file, but then i also figure that it has it's merits being put alongside the actual code of the function -- i guess people are far more likely to be reading source files than header files. Any thoughts?

I would probably put it in the headers simply because if you compile a static or dynamic library and then people link programs against that later, they might not ever see the source code.  For example, I use Winsock2 every now and then.  I don't have the source to it, but I can look at the header.

 

 

Edit:  I have no idea what the correct way is though since I've never coded anything in C that's not for exclusively my own use.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.