1 Programming Languages Supported by GCC
1 Programming Languages Supported by GCC
The abbreviation GCC has multiple meanings in common use. The current official meaning is “GNU Compiler
Collection”, which refers generically to the complete suite of tools. The name historically stood for “GNU C
Compiler”, and this usage is still common when the emphasis is on compiling C programs. Finally, the name is also
used when speaking of the language-independent component of GCC: code shared among the compilers for all
supported languages.
The language-independent component of GCC includes the majority of the optimizers, as well as the “back ends”
that generate machine code for various processors.
The part of a compiler that is specific to a particular language is called the “front end”. In addition to the front ends
that are integrated components of GCC, there are several other front ends that are maintained separately. These
support languages such as Pascal, Mercury, and COBOL. To use these, they must be built together with GCC proper.
Most of the compilers for languages other than C have their own names. The C++ compiler is G++, the Ada compiler
is GNAT, and so on. When we talk about compiling one of those languages, we might refer to that compiler by its
own name, or as GCC. Either is correct.
Historically, compilers for many languages, including C++ and Fortran, have been implemented as “preprocessors”
which emit another high level language such as C. None of the compilers included in GCC are implemented this way;
they all generate machine code directly. This sort of preprocessor should not be confused with the C preprocessor,
which is an integral feature of the C, C++, Objective-C and Objective-C++ languages.
Advantage of c in linux
Speed, power, efficiency, well supported libraries, generally. Almost everything (But not absolutely everything.) has
at least C bindings one can use.
Not to mention you're guaranteed to have the standard C library to handle a great deal of the core functionality of the
2
program
C is strongly linked with linux/unix .The kernel of Unix/Linux is written in C.Running C in linux/unit has several advantages
.The most important among it is full word length utilization.
Consider the following C program
#include
int main()
int a;
float b;
return 1;
Even though your computer is 32 or 64 bit computer, Turbo C is utilizing only 16 bits to int which should have been 32 bits(Int
is allocated with a space equal to wordlength of the computer)
Ok…running C program in linux/unix utilizes full word length.what’s it’s use for me??
3
The maximum number of singed int datatype(normal int) that can be accomodated if you run c in windows is ((2^15)-1)=32767
that means if ‘a’ is made to store number greater than 32767 it will cause data overflow and you will get garbage values.(Read
How C Compiler decides the Garbage values in case of data overflow for more information)
The maximum number of singed int datatype(normal int) that can be accomodated if you run c in linux is ((2^31)-
1)=2147483647 (assuming your comp is 32 bit)
so the int variable ‘a’ can store a maximum value of 2147483647.Compare with this mere 32767..
This is for int datatype consider other datatypes such as float,long double,double,long int etc..
Imagine how many big values it can store
4
Note:
To know more about commands used in VI editor checkout,
Vim/Vi Editor Commands Cheat Sheet
4. Press I to insert text and start writing the C Program into it.
5. After coding it.Just press Esc button and type :wq
Note:
Here :wq specifies save and exit.
6. The next step after coding is compilation part.To compile C Program type the following in Terminal,
CC Filename.c
If you had any error again enter into text editor,
Vi Filename.c after fixing the error press :wq (Save and exit).
That’s it In this tutorial I have simulated a Year 2038 bug or Y2k38 using C Program. The following ANSI C programme when compiled
simulates the bug.
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
int main (int argc, char **argv)
{
time_t t;
t = (time_t) 1000000000;
printf (“%d, %s“, (int) t, asctime (gmtime (&t)));
t = (time_t) (0x7FFFFFFF);
printf (“%d, %s“, (int) t, asctime (gmtime (&t)));
t++;
printf (“%d, %s“, (int) t, asctime (gmtime (&t)));
return 0;
}
Output :
1000000000, Sun Sep 9 01:46:40 20012147483647,
Tue Jan 19 03:14:07 2038-2147483648,
Fri Dec 13 20:45:52 1901