Is there C a compiler that works they way it did before C++ ? I would like to won one for use on OS X.
Thank you for your help.
Jim Adrian
As far as I can tell there are no actively maintained C compilers that support the original K&R definition of C. You may be able to run an old K&R C compiler under some sort of emulator as in the computer history simulation project. On the other hand ANSI C, though influenced by C++, was designed to be forward compatible with most K&R style C code. If you are leaning C for the first time and not interested is reliving the historical evolution of the C programming language, I would suggest starting with the C99 standard of the language which includes complex numbers and variable length arrays. Note that neither of these C99 language features resemble anything in C++ and instead represent a separate evolution of the original C language. Any recent version of gcc with the option -std=gnu99 can be used to compile C99 compliant C code.jamesadrian wrote:Is there C a compiler that works they way it did before C++ ? I would like to won one for use on OS X.
Thank you for your help.
Jim Adrian
What is it about cc or gcc that doesn't work for you?jamesadrian wrote:Is there C a compiler that works they way it did before C++ ? I would like to won one for use on OS X.
You can go back as far as C89 (iso9899:1990) which is later than K&R. (-std=c89). There is also -std=c99 and the default which is -std=c11, the latest standard. Changing c11 to gnu11 allows all the (useful) gnu extensions.jamesh wrote:Can you specify to gcc that you want a specific version of C to be used? I thought that was possible. Whether you can make it go back that far I don't know.
Code: Select all
sudo apt-get install gcc-4.9-docI am sorry, but that is rediculous.jamesadrian wrote: I am concerned about the structural constraints imposes by C++
Just out of curiosity, what are structural constraints?MarkHaysHarris777 wrote:C++ has no structural constraints; none.
Google doesn't seem to know what they are eitherejolson wrote:Just out of curiosity, what are structural constraints?MarkHaysHarris777 wrote:C++ has no structural constraints; none.
You really don't need to use classes in C++, which means you can use all the other benefits, and they are very useful benefits, some of which are outlined above, to which I would add function templates, and some of the other std:: libraries like vector, map etc which means you no longer have to write lots of boilerplate code. Note they are classes, but they are very optimal, and you don't need to use you own classes to use library classes.jamesadrian wrote:Marcus,
I don't want to build classes and use inheritance and I didn't understand the degree to which it might be an obligation in C++ . Thank you for your very informative answer.
Jim Adrian
Code: Select all
C++ = {x | x ∈ ANSI_C } ∪ {y | y ∈ c++_classes }
so
∀ x ∈ ANSI_C ⇒ x ∈ C++ This answer is slightly oversimplified, but yes... C is a subset of C++ ...often, as is the case for gcc, the compiler is the same one (for all intents and purposes).davenull wrote:so if a code works by a ANSI C compiler , it also works by a C++ compiler
![]()
to say it mathematically, ANSI C is a subset of C++
![]()
Getting back to your original question...jamesadrian wrote:Is there [a C] compiler that works they way it did before C++ ? I would like to [own] one for use on OS X.
Code: Select all
sudo apt-get install clang
Code: Select all
clang -Wall -o helloworld hello.c
Code: Select all
clang -v
Code: Select all
/usr/lib/llvm-3.5/bin/