Is C open source?

CCompiler ConstructionOpen Source

C Problem Overview


Does C (or any other low-level language, for that matter) even have source, or is the compiler the part that "does all the work", including parsing? If so, couldn't different compilers have different C dialects? Where does the stdlib factor into this? I would really like to know how this works.

C Solutions


Solution 1 - C

The C language is not a piece of software but a defined standard, so one wouldn't say that it's open-source, but rather that it's an open standard.

There are a gazillion different compilers for C however, and many of those are indeed open-source. The most notable example is GCC's C compiler, which is all under the GNU General Public License (GPL), an open-source license.

There are more options. Watcom is open-source, for instance. There is no shortage of open-source C compilers, but without a doubt the most widespread one, at least in the non-Windows world, is GCC.

For Windows, your best bet is probably Watcom or GCC by using Cygwin or MinGW.

Solution 2 - C

C is a standard which specifies how C compilers should generate programs.
C itself doesn't have any source code, just like a musical note doesn't have any plastic.

Some C compilers, such as GCC, are open source.

Solution 3 - C

C is just a language, and a standardised one at that, too. It pretty much is the compiler that "does all the work". Different compilers did have different dialects; before the the C99 ANSI standard, you had things like Borland C and other competing compilers, that implemented the C language in their own fantastic ways.

stdlib is just an agreed-upon collection of standard libraries that are required to be present in any ANSI C implementation.

Solution 4 - C

To add on to the other great answers:

Regarding different dialects -- there are some additional features added to C that are compiler specific. You can provide the command line flag -std=... to gcc to specify the C standard that you want to use, each has slight variations/additions to syntax, the most common is probably c99.

Each compiler tends to implement a few different extras, for example, typeof() is not in the C standard and so compilers do not have to implement this but nevertheless it is useful and most compilers provide it. Here is a list of gcc C extensions

The stdlib is a set of functions specified in the C standard. Much like compilers, stdlib can have different implementations. The GNU implementation is open source, as is gcc, but there are other compilers and could be other implementations of stdlib that are closed source.

Solution 5 - C

The Compiler would determine all the mappings from C to Assembly etc... but as far as someone owning it.....noone really owns C however the ANSI/ISO determines the standards

Solution 6 - C

GCC's C compiler is written in C. So we know there are at least one C compiler written in C.

GNU's stdlib (glibc) is also written in C (stdio.h, stdlib.h). But it also has some parts written in assembly language.

Solution 7 - C

A really good question. http://en.wikipedia.org/wiki/Denotational_semantics">There is a way to define a language standard (not the implementation!) in a form of a "source code", in a strict and unambigous language. Unfortunately, all of the old languages, including C, are poorly defined. But it is still possible to translate that definitions into a source code form.

Another approach is to define a language via its http://en.wikipedia.org/wiki/Operational_semantics">operational semantics, often in a form of a simple (and unefficient) reference implementation.

Solution 8 - C

Helgi Hrafn Gunnarsson has written the main answer but I thought it would be worth noting that you can effectively end up with dialects too.

The compilers should do the same thing with regards to whichever standard they support (which these days should be pretty much all the same version) but there are grey areas. The way in which the compilers work for 'undefined' functionality for example. If the C specification says that the behaviour is undefined for a specific case then the compiler can do pretty much what it wants.

There are also examples of functions added to the libraries (and new libraries added) by the compiler makers to support specific platform traits, create a competitive advantage or simply to make life easier. The cynical might suggest that some of these are added to help lock people into a specific compiler too.

Solution 9 - C

I would say that C as a language is not open source. As pointed out by many, you can download GNU licensed compilers and libraries for free, but if you wanted to write your own C compiler, you would need to follow the ISO C standards, and ISO charge hard cash for the specification of the C language, which at the time of posting this is $178. So really the answer depends on what elements you are interested in being free and open source.

Solution 10 - C

I'm not sure what your definitions of "open source" are.

For the standardization process, it is possible for anyone to participate, but if you want to be able to vote then you will need to pay to join your national body (for instance, ANSI for the USA, BSI for the UK, AFNOR for France etc.). As a rule most standards body memberships are paid by corporations. That said, the process is fairly open. You can access discussion papers on the standards web site.

The standards themselves are not free either. The ISO pdf store currently sells the C standard for 198 swiss francs. Draft copies of the standard can be found easily for free.

There are plenty of open source implementations of both compilers and libraries.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHypercubeView Question on Stackoverflow
Solution 1 - CTeekinView Answer on Stackoverflow
Solution 2 - CSLaksView Answer on Stackoverflow
Solution 3 - CnesvView Answer on Stackoverflow
Solution 4 - CJesse CohenView Answer on Stackoverflow
Solution 5 - Cuser475353View Answer on Stackoverflow
Solution 6 - CPablo Santa CruzView Answer on Stackoverflow
Solution 7 - CSK-logicView Answer on Stackoverflow
Solution 8 - CColin NewellView Answer on Stackoverflow
Solution 9 - Cuser2827968View Answer on Stackoverflow
Solution 10 - CPaul FloydView Answer on Stackoverflow