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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.