Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > C compiler internals

Reply
Thread Tools

C compiler internals

 
 
Guru Jois
Guest
Posts: n/a
 
      05-27-2007
Hai,

Can I get some docs or links to learn the C compiler internals
from basic to advanced. It must contains good documentation of how
compilers allocates memory to variables.

Bye
Guru Jois

 
Reply With Quote
 
 
 
 
Jensen Somers
Guest
Posts: n/a
 
      05-27-2007
On Sun, 27 May 2007 04:52:52 -0700, Guru Jois wrote:

> Hai,
>
> Can I get some docs or links to learn the C compiler internals
> from basic to advanced. It must contains good documentation of how
> compilers allocates memory to variables.
>
> Bye
> Guru Jois


There are a lot of different C compilers out there and some of them are
closed source. I don't think the MSVC compiler has a lot of in-depth
documentation on how it works internally.

Take a look at the following link for some information about the GCC
compiler:
http://en.wikibooks.org/wiki/Categor...iler_Internals

Hope it helps a bit.

Regards,
Jensen
 
Reply With Quote
 
 
 
 
Chris Dollin
Guest
Posts: n/a
 
      05-27-2007
Guru Jois wrote:

> Can I get some docs or links to learn the C compiler internals
> from basic to advanced. It must contains good documentation of how
> compilers allocates memory to variables.


Why?

I mean, what problem do you hope to solve with this information?

Compilers allocate memory -- and registers -- to variables in
ways that will make the code faster, or smaller, or the compiler
easier to write, or faster, or smaller; the tradeoffs differ
even between compilers for the same architecture and can often
be controlled by command-line switches; what are you going to
do with the answer?

--
Interpreting Hedgehog
"We did not have time to find out everything we wanted to know."
- James Blish, /A Clash of Cymbals/

 
Reply With Quote
 
Serve Laurijssen
Guest
Posts: n/a
 
      05-27-2007

"Guru Jois" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hai,
>
> Can I get some docs or links to learn the C compiler internals
> from basic to advanced. It must contains good documentation of how
> compilers allocates memory to variables.


read books on compiler design maybe, although that has nothing to with C
anymore


 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      05-27-2007
Guru Jois wrote:
> Hai,
>
> Can I get some docs or links to learn the C compiler internals
> from basic to advanced. It must contains good documentation of how
> compilers allocates memory to variables.
>
> Bye
> Guru Jois
>

Hi guru

How lcc-win32 allocates memory to variables
-------------------------------------------

For lcc-win32 there are several types of variables:
1) File scope variables, that are allocated in the initialized variables
section of the executable. For example:
int table[] = {1,2,3,4,5,6};
Lcc-win32 will reserve space in the data section for six 32 bit
numbers and initialize that to the binary values given.
Each object code file (.obj) can contain contributions to this
segment. The linker combines them all into a single segment.
2) File scope variables without any initial values. For example:
int table[6];
Lcc-win32 will reserve space for 6 32 bit numbers in the
uninitialized variable section (bss) and the value of them will be
set to zero when the system loads the program into memory.
3) Local variables.
They are allocated into a memory block reserved for temporary
storage. This is normally the stack segment. At entry of a function,
its activation record will be built, and the stack will be adjusted
to contain space for all local variables of the function. This
storage will be reclaimed when the function exits.

4) Variable length automatic variables
This variables will be allocated in the stack in a similar way as
(3) but they are not part of the activation frame since the
activation frame is fixed length, and this variables are variable
length. Example:
int fn(int n)
{ int table[n]; // <<<--- variable length array (VLA)
}
 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      05-27-2007
Guru Jois wrote:
> Hai,
>
> Can I get some docs or links to learn the C compiler internals
> from basic to advanced. It must contains good documentation of how
> compilers allocates memory to variables.
>
> Bye
> Guru Jois
>

Hi guru

How lcc-win32 allocates memory to variables
-------------------------------------------

For lcc-win32 there are several types of variables:
1) File scope variables, that are allocated in the initialized variables
section of the executable. For example:
int table[] = {1,2,3,4,5,6};
Lcc-win32 will reserve space in the data section for six 32 bit
numbers and initialize that to the binary values given.
Each object code file (.obj) can contain contributions to this
segment. The linker combines them all into a single segment.
2) File scope variables without any initial values. For example:
int table[6];
Lcc-win32 will reserve space for 6 32 bit numbers in the
uninitialized variable section (bss) and the value of them will be
set to zero when the system loads the program into memory.
3) Local variables.
They are allocated into a memory block reserved for temporary
storage. This is normally the stack segment. At entry of a function,
its activation record will be built, and the stack will be adjusted
to contain space for all local variables of the function. This
storage will be reclaimed when the function exits.

4) Variable length automatic variables
This variables will be allocated in the stack in a similar way as
(3) but they are not part of the activation frame since the
activation frame is fixed length, and this variables are variable
length. Example:
int fn(int n)
{ int table[n]; // <<<--- variable length array (VLA)
}
 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      05-27-2007
Guru Jois wrote:
> Hai,
>
> Can I get some docs or links to learn the C compiler internals
> from basic to advanced. It must contains good documentation of how
> compilers allocates memory to variables.
>
> Bye
> Guru Jois
>

Hi guru

How lcc-win32 allocates memory to variables
-------------------------------------------

For lcc-win32 there are several types of variables:
1) File scope variables, that are allocated in the initialized variables
section of the executable. For example:
int table[] = {1,2,3,4,5,6};
Lcc-win32 will reserve space in the data section for six 32 bit
numbers and initialize that to the binary values given.
Each object code file (.obj) can contain contributions to this
segment. The linker combines them all into a single segment.
2) File scope variables without any initial values. For example:
int table[6];
Lcc-win32 will reserve space for 6 32 bit numbers in the
uninitialized variable section (bss) and the value of them will be
set to zero when the system loads the program into memory.
3) Local variables.
They are allocated into a memory block reserved for temporary
storage. This is normally the stack segment. At entry of a function,
its activation record will be built, and the stack will be adjusted
to contain space for all local variables of the function. This
storage will be reclaimed when the function exits.

4) Variable length automatic variables
This variables will be allocated in the stack in a similar way as
(3) but they are not part of the activation frame since the
activation frame is fixed length, and this variables are variable
length. Example:
int fn(int n)
{ int table[n]; // <<<--- variable length array (VLA)
}
 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      05-27-2007
There is a bug in the thunderbird client apparently...
It sent the message three times

Sorry about this

jacob
 
Reply With Quote
 
Tor Rustad
Guest
Posts: n/a
 
      05-27-2007
Guru Jois wrote:
> Hai,
>
> Can I get some docs or links to learn the C compiler internals
> from basic to advanced. It must contains good documentation of how
> compilers allocates memory to variables.



Try, comp.compilers and check their FAQ.


--
Tor <torust [at] online [dot] no>
 
Reply With Quote
 
Barry Schwarz
Guest
Posts: n/a
 
      05-27-2007
On 27 May 2007 04:52:52 -0700, Guru Jois <(E-Mail Removed)> wrote:

>Hai,
>
> Can I get some docs or links to learn the C compiler internals
>from basic to advanced. It must contains good documentation of how
>compilers allocates memory to variables.
>


Your posts indicate you are a relative newcomer to C and programming.
It is much too early for you to be jumping into a topic this complex.

Why do you care how one particular compiler allocates variables? It
may have nothing to do with how your compiler does so. It may change
completely in the next version of the compiler.

At this stage in your development, you should not be writing code that
depends on a particular allocation technique. Concentrate on the
portable features of the standard language, which is the area this
newsgroup deals with.


Remove del for email
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
.Net VC++ Java C++ Windows Internals Unix Internals Jobs Gooogle Java 2 05-11-2007 02:23 PM
.Net VC++ Java C++ Windows Internals Unix Internals Jobs Gooogle C++ 1 05-10-2007 06:53 PM
.Net VC++ Java C++ Windows Internals Unix Internals Jobs Gooogle C Programming 0 05-10-2007 06:39 PM
.Net VC++ Java C++ Windows Internals Unix Internals Jobs Gooogle Javascript 0 05-10-2007 06:38 PM
Good book on the asp.net internals? Abhishek Srivastava ASP .Net 2 04-21-2004 04:52 PM



Advertisments