Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been looking for various licenses that I can use for an open-source project of mine, but all of the projects that I've seen, with all kinds of licenses, appear to have a giant, obnoxious (in my opinion) notice in each source file that states that the file is listed under a certain license. I don't think that I've found a single source project that isn't public domain that doesn't have a notice like that.

This just seems like a waste of time and file space. I plan on putting @license and @author tags in my projects, but I don't see why I need to list such a giant notice in each individual file if I don't want to make my code public domain.

Is there any reason why I would want to include such a notice in my projects, or would simply including a notice in the README and a @license tag be good enough? Does this affect the "clearly stated" rule of most licenses, or is it just overkill so that people won't argue?

share|improve this question
Your editor should allow you to fold/hide the license into 1 line. – Pubby Dec 18 '11 at 16:34
Realistically, if someone steels your code, renames a variable and remove the copyright would a court of law consider these 2 files identical? – NoChance Dec 18 '11 at 17:01
@Emmad: No, a court would not say they are identical. (But they might be "essentially identical".) Yes, a court would say it's copyright infringement. – Andrew Dalke Dec 18 '11 at 18:49

In my understanding, the GPLv3 strongly suggests (or even perhaps requires, at least that how I understand the text How to Apply These Terms to Your New Programs, after its section 17) a copyright notice in every source file. It says

To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year>  <name of author>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <>.

And GNU projects which are FSF owned, like GCC, have such a notice in every file.

I also know of a program (J.Pitrat's CAIA system) which has been refused on a free software community web site because it had no such notice in every file.

I am not a lawyer, but I believe that such notice is practically mandatory in every source file of a GPLv3 program.

share|improve this answer
It can't be mandatory because there are systems, like Smalltalk images, which don't express source code as files. They say "safest" and "should", not "must." What they recommend is an easily understood guideline with little chance of someone making an error, but it is definitely not "practically mandatory." – Andrew Dalke Dec 18 '11 at 18:33
I agree, and I said "source file" on purpose. Actually, CAIA's system is a bit like Smalltalk: the image is in data files, and the CAIA "source files" I mentionned are generated C files. However, my GCC MELT (a branch of GCC, under FSF copyright) is also meta-programmed, and I do take care to generate copyright notice comments in generated C files (and I put them in hand-written C & MELT code). – Basile Starynkevitch Dec 18 '11 at 18:36
Point taken. I know now one paragraph about MELT. In general it's best that generated files include the copyright notice as it's very hard to "attach" the license otherwise. Eg, "yacc" and "lex" are restricted in what they can do. – Andrew Dalke Dec 18 '11 at 18:57
To be picky, it might be difficult to generate a year for the copyright of generated files. GCC itself has a small issue about that for gengtype (the generator of code for the garbage collector inside GCC), but nobody really cares... – Basile Starynkevitch Dec 18 '11 at 18:59

I've seen many projects which only mention the license in the README or in a LICENSE or COPYING file.

Your software is automatically covered under copyright, as agreed in international law. (Unless you are working for the US government or some other organization for which copyright does not apply.)

If someone uses your software then they must make sure to follow the license agreement, or follow the fair use restrictions on what they can do.

Suppose that person wants to use one of the files in your code distribution, which of course requires a copy and hence copyright law applies. By default they do NOT have the right to use your software under copyright law. It's only when they know and follow the license restrictions that they are allowed to use it.

So if they use a file without a software license then they are breaking copyright law. Since all the licenses say something like "The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software", they are obliged to put that license somewhere.

That can be in the file itself, or when I've used code as library I put the relevant portions into its own directory and added a "README" or "LICENSE" into that subdirectory.

In short, you don't need to put the license in each file. I think it's overkill. There's no extra legal protection in doing so. It does help a downstream user somewhat, but not by much.

I think the tradition of lots of comment-based metadata (license, creation date of each function, changelog, etc.) are very old traditions which exist because they are easy to do and which more a talisman than useful.

For example, the default Eclipse template adds what I think of as useless metadata before each function, which I think is much better captured by version control. But that practice is common in many shops.

share|improve this answer
For example, I don't see anything related to licensing in Rails source files at all. – Anton Barkovsky Dec 18 '11 at 18:49
And of the 200 files in the top-level Python standard library, only 34 contain the word "copyright", and only 4 of those are for the Python Software Foundation, which controls the copyright to Python. – Andrew Dalke Dec 18 '11 at 18:58

The problem is that it's very easy to dis-aggregate a single source code file from its larger project, such as someone just checking out, emailing, downloading one file, without the rest that contains the full copyright. And then that file can get passed along ad-infinitum into time, to Nth parties who may have no idea of the files origins.

The copyright notice at the top reminds anyone who runs across that lone file that it is in fact copyrighted, not public domain, and thus some license may or may not be involved in its distribution or use. Versus letting the finder make their own random assumptions.

share|improve this answer
Isn't it just as easy to dis-aggregate through copy-paste various fragments of a source file as well? What then? This argument seems inconsistent to me. – Travis Griggs Feb 19 '15 at 23:59

There is no secret superpower meeting in an underground bunker that says what you must put it in each source file.

It does make it clear to the user that this file is under whatever license and in fact most GPL software contains a short preamble saying to read license.txt. Remember projects get split up and files get reused so only putting the message in a single file might not be a good idea.

If in the unlikely event it ever went to court you might have more claim if you had clearly marked each file as your work and what license it was under - then nobody could claim they thought that this prticular file wasn't covered

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.