Take the 2-minute tour ×

It's a common practice to place copyright notices, various legal disclaimers and sometimes even full license agreements in each source file of an open-source project. Is this really necessary for a (1) open-source project and (2) closed-source project? What are you trying to achieve or prevent by putting these notices in source files?

I understand it's a legal question and I doubt we can get a fully competent answer here at programmers.SO (it's for programmers, isn't it?) What would also be interesting to hear is, when you put legal stuff in your source files, is it because "everyone does it" or you got legal advice? What was the reasoning?

share|improve this question
add comment

4 Answers

up vote 14 down vote accepted

Is this really necessary

No. It's not legally required. (IANAL, but I've seen this stated by one.)

If you've got a project where individual files might be taken out of context, it may be sensible - but it only requires a couple of lines, to say something like:

This file is part of <project> which is released under <license>.
See file <filename> or go to <url> for full license details.

For anything else, you can simply put a LICENSE text file in the project root, and any relevant details/credits/etc in the README file - it's still copyrighted (automatically), so it's just a question of being clear license-wise in the readme file.

share|improve this answer
+1 for not putting the whole license boilerplate. I just use one line: Copyright YYYY First Last. Subject to the XYZ license. –  Mk12 Aug 18 '12 at 21:40
add comment

You could, conceivably simply put your copyright notice that mentions a LICENSE file, however there is no guarantee that once released, your code will remain atomic. In fact, it is quite likely that bits and pieces of it will be remixed in at least several other projects.

This is why it is important to at least have the following in every source file:

/* Copyright (C) 1883 Thomas Edison - All Rights Reserved
 * You may use, distribute and modify this code under the
 * terms of the XYZ license, which unfortunately won't be
 * written for another century.
 * You should have received a copy of the XYZ license with
 * this file. If not, please write to: , or visit :

You accomplish two things by doing this:

  • Your copyright is asserted no matter how your code disintegrates and scatters in the future.
  • You make the terms of using, distributing and modifying it quite clear, even if someone happened to receive only a small part of a library that you wrote.

A lot of people also include their e-mail address under the copyright, which is helpful for receiving patches in the future. I received a patch last month for code that I wrote five years ago and had long forgotten about. Of course, that means maintaining an e-mail address and putting up with a bit of SPAM.

If ever you actually need to enforce your license, it is critical that the other party can't say that the terms were ambiguous or missing, all kidding aside.

Plus, it's fun to watch how bits and pieces of your code find their way into other bits and pieces of code over time. Most people play fair and respect copyright and license terms.

share|improve this answer
"the terms of the XYZ license, which unfortunately won't be written for another century." It's been 130 years and counting. :P –  Joe Z. Feb 1 '13 at 15:47
add comment

Just wanted to note Open Source != No Copyright.

Open Source relies on someone claiming copyright then adopting a specific legal document (Like the GPL) to give away that copyright.

So whatever you decided is suitable for closed source code is also suitable for open source code.

share|improve this answer
Altho there is more chance a single file will be taken elsewhere from an open source project than a closed source one, so maybe copyright notices in the heads of files make more sense in an open source project ... –  James Jan 6 '11 at 9:17
add comment

For any open-source project

You are defining the conditions under which the code is to be used and redistributed (or not, depending on those conditions).

At the very least, a license can answer questions such as:

  • Appropriation: Can someone take the code and evolve it into a different project? A good example of such a phenomenon is Google Chrome, which is based upon the open-source Chromium project.
    • Do they need to give you credit, seek permission, etc...
  • Commercial Use: Can your code be used commercially, such as within Photoshop as a third-party DLL? If so do different conditions apply?
  • Redistribution: Do any uses of your code have to be in software with a similar/identical license? Licenses such as the GPL which require this are called viral licenses (and I don't know if that's a negative term, or just a statement of fact).

Etc. That's by no means a comprehensive list, it's just to give you an idea of the questions a license would state clearly.

share|improve this answer
I think I understand that, but why should legal notices be put in each source file? Or if they shouldn't then why do people do it? –  mojuba Nov 17 '10 at 17:40
Sounds like a safe way of ensuring the license isn't lost if it's separated from the source code. –  Jonathan Hobbs Nov 17 '10 at 17:53
add comment

Your Answer


