GCC has a special exception that doesn't force you to use GPL for programs compiled with GCC. If I for example had program foo, how can I apply the classpath/GCC/linking exception to it as well? Do I have to modify the GPLv3 adding the exception or make a separate file stating the exception? Do I have to put a notice on every file that there is a special exception?
GCC has a special exception that doesn't force you to use GPL for programs compiled with GCC
Correct. Its output does not have to be under the GPL. Similarly:
- an image created with Photoshop doesn't need to follow the license that Photoshop is distributed under, even if fancy filters are used
- a picture taken and edited with an Apple iPhone isn't owned by Apple
- a document created with Microsoft Word doesn't need to be distributed under the same terms as MS Word itself
These all deal with what the program produces at runtime. GCC adds its own bits of code to the final binary, so it needs the exception to ensure that those small functions don't cause the whole program to be under the GPL. If this applies:
- Programs that use your library must use the GPL, and
- Your program includes part of itself in its output, and
- The part that is included is enough to be copyrightable (e.g. some bits of JSON/XML probably doesn't), and
- you don't want to place only those specific bits under a more permissive license
then you can consider using some of the GCC Runtime Library Exception. However, it's written very specifically for GCC, and mentions its name and behavior several times, so you'd need to modify it to fit your program. To apply it, add the full text somewhere in your project, and add the specific bits of the standard copyright header to every source file in which it applies.
However, you seem to mix in your question the "GCC Runtime Library Exception" and the "GNU Classpath" exception. If you actually want the latter, and you instead want to allow others to link to your library without being considered under the GPL, use LGPL instead.
Finally, if you truly do not want to "permit modifications of the combined work and reverse engineering for debugging such modifications" and confuse many people who aren't familiar with GPL2 + classpath exception, then use this file as your LICENSE, and add "with the Classpath Exception" in your copyright header in each source file.