What is machine dependency?

Questions by Bhawan Thakur

Showing Answers 1 - 2 of 2 Answers

Shilpa

  • Oct 24th, 2011
 

Machine dependency mean we are bound to machines or platform.for example we have some code to execute but we can only execute it on a particular os or required any particular software to run it.

  Was this answer useful?  Yes

pravallika

  • Nov 29th, 2011
 

There will be times where machine dependencies cannot be avoided, and will be required in the code. These dependencies can be based on the operating system (VMS vs. Unix), or they can be based on the actual machine type or flavor of Unix that is running. Not all variants of Unix are created equal, and sometimes there can be significant differences among machines. This section describes how to handle such machine dependencies in your code.

There are two major ways of dealing with machine dependencies. The first is to isolate them into separate source files, and compile only the one that applies to the machine you're on. The second is to have the machine-dependent code in-line, and use the C preprocessor to select the appropriate version.

The first solution, separate source files, is appropriate when there are whole routines that are implemented differently under the different operating systems. This option is normally used for differences between VMS and Unix; only rarely will you have separate source files for variants of Unix. The RTL uses this method internally quite often. The filenames should then by convention end in an underscore and the OS name, for example, ``open_input_file_vms.c'' and ``open_input_file_unix.c''.

Once you have the files separate, you must somehow get the appropriate one to compile during a build. This is handled in the imakefile (see Section , vimake, for details on the imakefile). The MODULE_LIST (or other appropriate macro) would be defined differently based on the machine type. Since vimake uses the C preprocessor, the rules listed below for machine-dependent preprocessor symbols should be used

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions