what is diff compile time and runtime ?

Posted by Yugandhar under Interview Questions on 9/5/2012 | Points: 10 | Views : 21397 | Status : [Member] | Replies : 3
what is diff compile time and runtime ?
about memory allocation for variables or data memebers




Responses

Posted by: Muhsinathk on: 9/6/2012 [Member] Bronze | Points: 25

Up
0
Down
Compile time

1."Compile time" is when you build your code - when the compiler converts your source code into IL.
2.The source code must be compiled into machine code in order to become and executable program.
This compilation process is referred to as compile time.
3.The terms "runtime" and "compile time" are often used by programmers to refer to different types of errors.
A compile time error is a problem such as a syntax error or missing file reference that prevents the program from successfully compiling.
The compiler produces compile time errors and usually indicates what line of the source code is causing the problem.

Runtime
1."Runtime" is when your code is executed - for ASP.NET, when a page request is made.
2. A compiled program can be opened and run by a user. When an application is running, it is called runtime.
3.If a program's source code has already been compiled into an executable program, it may still have bugs that occur while the program is running.
Examples include features that don't work, unexpected program behavior, or program crashes.
These types of problems are called runtime errors since they occur at runtime.

A compiled program can be opened and run by a user. When an application is running, it is called runtime.

Yugandhar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vasanthmvp on: 9/6/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Compile time is where your compiler transforms your source code to a machine understandable language. During the compile time, it processes through various stages:
Creation of Symbol table, Syntax analysis, Semantic analysis, Code optimization, Code Generation & Error Handling. Here at the respective stages, different types of errors are encountered.
Runtime is during the execution process(Eg: Page request is made. or looping through a variable instances, etc). Runtime errors are handles after the successful compilation.
Simply :
The static variables are allocated with memory in the compile time.
The variables that are created at runtime(during the execution process), the memory is allocated for them at run time.

The compile time errors may occur with an error in syntax.
This run time errors may be based on the user input like divide by zero exception, stack over flow, pointer unavailability, wrong address reference, referring null string, etc.

For further info, Visit the following links:

http://stackoverflow.com/questions/7372024/allocation-of-memory-c-compile-time-run-time

http://stackoverflow.com/questions/1519274/what-is-the-difference-between-compile-time-and-run-time

Regards,

Awesome Coding !! :)

Yugandhar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 9/6/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Memory allocation at compile time is also called static allocation.
Memory allocation at run time is also called dynamic memory allocation.
When you define a variable:
int a[10];
The space for a is allocated during compile time.
The reason is, the storage size is already known for int variable and (10 * sizeof(int)) is the total size needed.
If you declare
int *a;
The size of storage needed is not known at compile time.
So, you can call malloc() and pass a variable to it as parameter. And this allocation will be done during runtime.
Since the parameter passed to malloc() is a variable, everytime a different sized memory chunk can be allocated.

Source URL :
http://en.allexperts.com/q/C-1587/compile-run-time-mem.htm

Yugandhar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response