top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How a compiler works?

+1 vote
536 views

In general, how a C language written program is converted into a binary by a C compiler ?

posted Aug 31, 2013 by Vikram Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

This is how a compiler works -

Lexing - break up the text of the program into "tokens"
Parsing - convert the sequence of tokens into a parse tree, which is a data structure representing various language constructs: type declarations, variable declarations, function definitions, loops, conditionals, expressions, etc.
Optimization - evaluate constant expressions, optimize away unused variables or unreachable code, unroll loops if possible, etc.
Translate the parse tree into machine instructions (or JVM byte code)

answer Aug 31, 2013 by Salil Agrawal
Similar Questions
0 votes

I am looking for detailed description of optimization flags that are provided by GCC compiler ?

+2 votes

I need to use microhttpd.a and pthread.a to build a cross-compiled program to be deployed on an arm-linux-gnueabihf device.

Where can I find instructions on how to do this? Or, is this simply a matter of downloading the source code and compiling (on a 64 bit UbuntuPC) to a library with my existing gcc-arm-linux-gnueabihf-4.8 cross-compiler?

While I may be able to find microhttpd.a and pthread.a binaries for an arm-linux-gnueabihf device, they will likely have been built with a different version of gcc-arm-linux-gnueabihf, which, I fear, could open up a can of worms.

+2 votes

What steps are performed by a compiler and how many types of compilers are present and used frequently ?

...