Does anyone know if the source code for Objective-C is still available from when it was just a pre-processor? Would be curious to see how it was implemented back then.
Thanks.
The Clang LLVM rewriter (rewriter is documented below there) can rewrite Objective-C into C (and is being used by some to compile Objective-C for the Xbox and Windows).
Some discussion here:
http://permalink.gmane.org/gmane.comp.compilers.llvm.devel/32019
The only source-available implementation of Objective-C is GCC. The GCC archive at ftp.gnu.org/pub/gnu/gcc contains versions back to 1.42, while ftp.gnu.org/pub/old-gnu/gcc has some versions slightly older than that. The earliest implementations within GCC were, I believe, preprocessors, so that's probably your best bet.
Related
I heard that GCC actually assumes registers, and requires CPU to have them to work.
What work should be done to remove this dependency, and port GCC to some register-less non-Von Neuman arch, like Multiclet?
Did somebody tried this? Is there some project and experience one can use if wants to work on this ?
If not, is there some other FOSS compiler that can be ported to something like Multiclet. LLVM has pretty much the same requirements like GCC, and it is unsuitable for me since I don't know C++. So it needs to be plain C. I hear that GCC is also adding C++ code now. But I can use some older version as starting point.
Multiclet's C99 compiler is not closed source. Sources are available at their community suite. One may google it by name 'multiclet mcc lime'.
I was looking into using Apple's Blocks runtime with clang on Linux, and I uncovered the incompatibility issues with the GNU libc's <unistd.h>. Looking around a bit for more information I found one user suggesting:
Oh well time to use a different libc? I hear FreeBSD has a nice one! :-)
As seemingly implied, this is a rather silly reason to use a different libc. But that did make me think:
Why would you ever swap your C library? Are there advantages/disadvantages to using one over the other (e.g. GNU libc vs. FreeBSD libc)? (I suppose this also applies to libstdc++ vs. libc++).
I can think of three reasons off the top of my head.
Legacy Reasons: You have code written against the old Rogue Wave,
Size: There's musl and dietlibc,
To Perform Android Cross Compile using Bionic
So I'm working on this C/C++ library, and I'm using the GNU compiler, which supports the latest standard of C and C++.
I want to make my library compatible with the VC++ compiler which only supports C89/C90, not the newer C standards that allow variable declarations after other statements inside of a function body.
Is there a tool I can use that will make all my variable declarations at the beginning of the function bodies?
My library is quite large and having a tool to do this task will make the process easy.
Sorry for the anti-answer, but Visual C++ is not a C compiler. It may be a compiler for some old, outdated (22 years outdated, to be precise) language, which is not C. The best thing you should do is to advise people that are asking you for such support about this and request them to switch compiler and not use a broken one.
If this solution is really beyond your choice (it's not), then there are similar topics that you could look for:
How to compile c99-to-c89 convertor with clang?
https://github.com/libav/c99-to-c89/
If you think what I said makes no sense think again: It's a 22 year outdated C compiler. Think about the effort and money that people all over the world have spent to support it.
Edit: btw, that's C:
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
http://www.open-std.org/jtc1/sc22/wg14/www/standards
The built in atomic operations were introduced in gcc-4.1.2. However, I am using gcc on OpenIndiana which only has gcc 3.4.3. Now my question is how to use atomic operations in gcc 3.4.3? Moreover I have tried to use gcc 4.6.1 in OpenIndiana but it doesnt work, as it complains about some runtime libraries. If anyone has successfully used it, kindly let me know.
I would suggest you to upgrade your GCC compiler. A GCC 3 is an ancient thing.
If you cannot install a newer version of GCC, you should try compiling a GCC 4.6.1 compiler from its source code. (don't forget to compile it in a build tree outside of the source tree, and don't forget all the dependencies).
You did not mention or explained why your compilation of GCC 4.6.1 failed. What runtime libraries did it complain about? Did you run ldconfig after installing it?
GCC has great inline assembly support, so you could just use __asm to make your own variant of the various atomic ops. It'll be specific to your target platform however, so you'll need some good macros to switch to the right versions.
To add to existing answers - have you looked at Spec Files Extra Repository? I never used it myself but it seems like it offers gcc 4.6 compiler package.
On Solaris, the alternative could be to fall back to libc atomic_ops(3C) interfaces. These might or might not get inlined, but they're guaranteed always available (and always behave in the same way) no matter which compiler you use.
Beyond that, I second the suggestion to either upgrade your gcc, and/or to get the SunStudio 12.2 compilers (they're royalty-free; even if you only use it for testing, code quality tends to go up if it's made to work with more than one compiler ...). Yes, it'll install/run on OpenSolaris-based distributions as well.
I wanted to know what is the current standard C compiler being used by companies. I know of the following compilers and don't understand which one to use for learning purposes.
Turbo C
Borland C
GCC
DJGPP
I am learning C right now and referring to the K&R book.
Can anyone please guide me to which compiler to use?
GCC would be the standard, best supported and fastest open source compiler used by most (sane) people.
GCC is going to have the best support of the choices you've listed for the simple reason that it comes standard in GNU and is the target of Linux. It's very unlikely any organization would use the other three beyond possibly supporting some horrible legacy application.
Other C compilers you might look into include:
Clang: an up-and-comer, particularly for BSD and Mac OS X
Visual Studio Express: for Windows programming
Intel Compiler Suite: very high performance; costs money
Portland Group: another high-performance commercial compiler; used typically for supercomputers
PathScale: yet another commercial high-performance compiler
If you are starting to learn the language, Clang's much better diagnostics will help you.
To make your (job) applications tools section look better, GCC (and maybe Visual Studio) are good to have knowledge of.
GCC (which I use in those rare moments when I use C) or ICC (Intel C Compiler), though ICC is known for making code that runs slowly on AMD processors.
Depends on the platform you are using and planning to learn on or will do future development.
On Windows you can use Visual Studio Express C++ which supports standard ANSI C usage. Option two is Cygwin which is a library and tool set that replicates much of what you would use on Linux or other Unix style OS's ( it uses GCC ).
On the Mac you would want XCode which is the standard development tools including C compiler ( based on GCC ).
On many Unix type systems it will be cc or gcc depending on the OS vendor.
If you have the money some of the paid compilers like the Intel one are exceptional but likely won't be much help in learning the programming craft at this point.
If you use LINUX operating system GCC is the best compiler. You can separate each compiler steps like preprocessing , assembler , linker separately in GCC compiler using some command line options. You can analyze step by step of compilation of your C source code easily. I suggest to go for "GNU C COMPILER(GCC)". You can use "CC" command, its nothing but a symbolic link to GCC.
I can recommend OpenWatcom which was once used to develop Netware. Only supports IA-32 but does it well. Contains a basic IDE and a basic but competent profiler. Something for the real programmer :)
Then there is Pelles C which supports x86-64. It has a basic VC-like IDE but few support programs.
I like these two because the compilers are competent and you get going quickly without having to pore over manuals and wondering what the options mean.
If you are on windows use MinGW or like most have suggested ggo with GCC on Linux
Though ofcourse since it's commandline so you might find Dev-C++ and/or Code::Blocks, Eclipse CDT etc which are IDEs useful for you to make your job simpler.
There is no standard and each compiler and it's libraries differ from one another.
gcc is best and free. GO FOR GNU!