Ask your own question, for FREE!
Computer Science 20 Online
OpenStudy (anonymous):

what is intermediate code, object code, executable code in c language?

OpenStudy (e.mccormick):

Well, have you looked up the terms. Even in their regular meaning, not as tecnical jargon, there is something to be learned. Like how an object is some sort of item, an entire individual thing.

OpenStudy (anonymous):

Intermediate code is code generated by compilers and yet isn't aimed for any specific machine. This code is not meant to be used by programmers, but instead to be simple for a compiler to analyze. This has many advantages, because this way you can compile codes in many different programming languages into the same intermediate code and spend all your efforts in making an efficient compiler to complete the complication of the intermediate code for the specific machine. Examples: * The LLVM compiler infrastructure is capable of compiling many programming languages by converting them first into LLVM Intermediate Representation code and from that point work with this code * The C-- intermediate language is meant to have a dedicated efficient compiler and let new languages developers to spend less effort optimizing their compilers by compiling into C-- and use their compiler from that point. Object code, or maybe better to say Object files, are files that generated by the compiler for every 'translation unit'. In C (and C++ as well) the compiler compiles a single input file at a time. Each file first goes through the preprocessor that works out all the proprocessor directives (such as #define, #ifdef, #include, #pragma etc.) and outputs the actual code to be compiled. The preprocessed code is then passed as an input for the compiler and is called a 'translation unit'. The translation unit is then compiled into an object file. The object file contains compiled processor instructions and data, and the only thing that prevents it from being an 'executable' is the linking step which I'll describe in the next section. The problem with object files is that each of them is compiled for a single piece of code. Those pieces of code are compiled separately and the output lacks the required connections between them. For example, say I have a file main.c and another file util.c and I want to call a function foo() which is defined in util.c I compile main.c and util.c and get the object files main.o and util.o (sometimes main.obj and util.obj). The object file util.o contains the compiled function foo(), but main.o does not, because foo() is not defined in main.c and the compiler couldn't compile it. So at this point 'linking' is required. The linker takes all the object files and merges them into a single unit while resolving references to external symbols in each one So in our case it will connect the function call to foo() from main.o to the actual location of the function in the final unit. The linker then outputs a unified file out of all the object files, and this file could be an executable or a library (there are other options as well). Executables are meant to be executed by an operating system. They have some information about resources they need and so on and have an entry point where they start executing. Libraries do not have an entry point and are meant to be used by executables rather than executing on their own. I hope it helps If it's not clear then let me know, I'll try to explain \(\Large ☺\)

OpenStudy (anonymous):

Thanks @pitamar had to give a medal to your reply. you actually deserved more than just 1 medal. Thanks again for the help.

OpenStudy (anonymous):

I'm glad I could help =) You're welcome

OpenStudy (anonymous):

HI @pitamar thanks for your awesome reply. Just a question came in my mind... Is it possible to view (and edit) these files (Intermediate/object/executable) by compiling a hello.c program in dev c++ ?

OpenStudy (anonymous):

First of all it's not certain that your compiler uses an intermediate language. Also some compilers literally compile to assembly before compiling to processor instructions. (This is not considered 'intermediate language' because it is not meant for an 'abstract machine' but is targeted for a specific machine). Anyway, some compilers have options for outputing partially compiled files. For example GCC can output preprocessed files and assembly files instead of the final executable. I'm not sure about Dev C++ (nostalgia, I thought this compiler is dead hehe) but i'll try and see While intermediate language and assembly are both languages, which means that in theory you can actually go and simply edit the files, object files are already compiled which makes editions much more difficult. Changing object files is a lot like changing an executable, you'd have to work with an hex editor and change actual bytes in the file, which is probably not a good idea as it risk breaking it is very high. May I ask what are you trying to do? lol

OpenStudy (anonymous):

WOW super fast reply. Thx for the help.

OpenStudy (anonymous):

Sure no problem =)

OpenStudy (anonymous):

From what it seems Dev C++ is only an IDE, it wraps GCC-based compilers I actually thought it was a compiler of its own back then hehehe Anyway that means that what you're dealing with is GCC really You can see here: http://en.wikipedia.org/wiki/Intermediate_language#Languages among other things also a list of intermediate languages GCC uses during compilation.

OpenStudy (e.mccormick):

Pitmar, Dev C++ uses GNU as the back end so it is far from dead. All it really does is act as an IDE to help the development.

OpenStudy (anonymous):

Yes, I wrote it uses GCC-based compilers. But the IDE itself is not in active development for years now... I last used Dev c++ about 7 years ago, so I guess I forgot a little what it was hehe

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!