answersLogoWhite

0


Best Answer
  • 1st create source file using text editor for the compiler
  • 2nd check source file for syntax errors by the compiler
  • 3rd save it as object file by the compiler,
  • 4th combine object files and resolve external library references to create executable file by the linker.

You can get the detailed answer on P29-31 ,Problem_Solving & program_design_in_c.

First the source files must be pre-processed. This handles all the precompiler directives (such as #include which pulls in headers) and macro definitions (such as #define statements which perform text replacements). This creates intermediate files known as translation units, which are then passed to the compiler. Each translation unit is compiled into machine code to create an object file. Finally, all the object files are linked together along with any precompiled static library functions to create the executable.

There are three stages to the translation process: preprocessing; compiling and linking

User Avatar

Wiki User

7y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

8y ago

C programs must be preprocessed, compiled and linked to produce machine code. Preprocessing (also known as precompilation) handles all the macro definitions (lines beginning with a #), expanding those symbols wherever they appear in the actual code, thus creating intermediate but temporary source files where all macros have been stripped out. the simplest macro is the #include macro which pulls in the contents of a header file just as if you'd copy/pasted that header into your source. The macros within those headers must also be processed.

Once the project is preprocessed, the compiler itself takes over. Since the macro definitions have all been stripped out of the intermediate file, the compiler never sees them (hence it cannot help you to debug them). Compilation is the process by which each translation unit (the intermediate .c file) is converted into an object code file (not to be confused with object-oriented program code). Any errors encountered during compilation results in a compile-time error. These must be fixed before proceeding any further. The compiler will identify where those errors are in your source file, except when the errors are a result of incorrect macro expansion.

Once compiled, the object code files need to be linked together along with any required link libraries (both static and dynamic) to produce the final executable. Any errors encountered here will result in a link-time error.

Once linked, the executable can be executed. Any errors at this point are runtime errors (typically logic errors).

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

In C, executable code (that is, the instructions that are to be executed) must occur within functions. Some programming languages allow code to be executed outside of functions in what's known as a the "global block". PHP and JavaScript both allow code in the global block, which is executed immediately one after another.

With C, however, compilers need an "entry point", which is the function where the first instruction is to be executed. The name of this function depends upon which platform you're writing for.

Console applications (text-mode) can use the following:

int main()

{

/* your code here */

}

If you want to support command-line arguments in a console application, the entry point function is:

int main(int argc, char **argv)

{

/* your code here */

}

Note that both examples above also apply to X11 programming.

If you're writing a pure Win32 application, the entry point function looks like this:

int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprev, char *cmd, int show) {

/* your code here */

}

If you're using or programming for another environment, the entry point may be different. It's recommended you seek a tutorial for the specific environment you're coding for for further information and examples.

This answer is:
User Avatar

User Avatar

Wiki User

7y ago

Preprocessing, compiling and linking. The preprocessor primarily handles all the precompiler directives (#include, #define, etc), importing included files, stripping out comments and expanding macros to create intermediate files (translation units) that contain pure C code. This is why the C compiler cannot help you debug macros; the compiler never sees the macros, it only sees the code produced by the preprocessor. The preprocessed files are compiled to create one object file per translation unit. Each object file is compiled in isolation and essentially contains optimised machine code with symbolic references in place of offset addresses that have yet to be established. The linker uses these symbolic references to ascertain the correct offsets and link all the machine code instructions together to produce a single machine code executable.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

To make a C program an executable program, you run it through a compiler.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

I think you wanted to ask: how to get an executable file from my C source. The answer is: use a compiler.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

There is special program to do that, it's called C compiler.

This answer is:
User Avatar

User Avatar

Wiki User

5y ago

Preprocessing, compilation and linking.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What processes are needed to transform a C program to a machine language program that is ready for execution?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How c language convert into machine language?

With a compiler, which is a program that "knows" how to transform the programming language logic in to machine code and make it perform from that.


Why does micro processor work in assembly language?

Microprocessors work in microcode, not assembly language. Microcode processes machine instructions, which are often assembled from assembler languages; higher level languages often convert each line of code into multiple lines of assembler language before their ultimate compilation into an executable. The assembler language contains mnomonics that are used to translate each line of source code into a machine instruction. When those machine instructions are loaded in memory, the CPU will use microcode to interpret and execute those instructions. Barring some experimental CPUs that use non-traditional machine code (such as Sun's Java CPU), all production-class CPUs use machine instructions as their basis for software execution.


What in jit compiller?

The JIT (Just In Time) compiler takes the semi-compiled "byte-code" of a language (notably Java), and converts it into proper machine code before execution. This delays the startup time, but provides better execution time.


How does an interpreter translate high-level code to machine code?

A computer does not execute a program in a high level language. A computer executes a program in machine language. The high level language is converted into machine language by a compiler. Alternatively, an interpreter executes on the computer in machine language and the interpreter executes the high level language.


Machine language is what generation language?

Machine language is a first generation language.

Related questions

How c language convert into machine language?

With a compiler, which is a program that "knows" how to transform the programming language logic in to machine code and make it perform from that.


Is assembler low level programming language?

"Assembly language" is essentially a direct translation from machine language. But yes it is a low level language It is one level above pure machine code. In 1967 I first learned to program in machine code and then stepped up to the next level of assembler on an Elliott Brothers 803c computer. The previous answer has the direction wrong! Assembly is translated into machine code which is then loaded into the computer's memory in binary ready for execution.


Why does micro processor work in assembly language?

Microprocessors work in microcode, not assembly language. Microcode processes machine instructions, which are often assembled from assembler languages; higher level languages often convert each line of code into multiple lines of assembler language before their ultimate compilation into an executable. The assembler language contains mnomonics that are used to translate each line of source code into a machine instruction. When those machine instructions are loaded in memory, the CPU will use microcode to interpret and execute those instructions. Barring some experimental CPUs that use non-traditional machine code (such as Sun's Java CPU), all production-class CPUs use machine instructions as their basis for software execution.


What in jit compiller?

The JIT (Just In Time) compiler takes the semi-compiled "byte-code" of a language (notably Java), and converts it into proper machine code before execution. This delays the startup time, but provides better execution time.


What are the Feature of machine language?

what are the features of machine language?


How does an interpreter translate high-level code to machine code?

A computer does not execute a program in a high level language. A computer executes a program in machine language. The high level language is converted into machine language by a compiler. Alternatively, an interpreter executes on the computer in machine language and the interpreter executes the high level language.


Could a machine cycle contain more than one execution cycle?

No. Its the other way around. An execution cycle contains 4 or more machine cycles. Always.


What machine that processes data?

computer


What is a machine that processes data?

computer


Machine language is what generation language?

Machine language is a first generation language.


What is an instruction phase together with the execution phase called?

The instruction phase together with the execution phase is called a "Machine Cycle".


What is meant by machine language?

A language at the level of the machine it runs on. AKA Machine code, it's the underlying language that computer CPU's speak.