HI Guys
I am working at C project.
My task is to port this c made application to different platforms like Linux,Unix,Solaris etc.
I am looking fwd some resources.
So can anybody help me out?
Thanks
Aniruddha
HI Guys
I am working at C project.
My task is to port this c made application to different platforms like Linux,Unix,Solaris etc.
I am looking fwd some resources.
So can anybody help me out?
Thanks
Aniruddha
Should not be difficult at all to port a C application. The real question to ask is what graphics libraries did you use, and there lies let obsticle. You can't port API's because they are vendor specific, unless it is pure Win32 than you can use it on any Microsoft version. The C language definition is supported on most every system though, but this is just the basic definition C99 or ANSI C.
Conditional Compilation
1978 Silver Anniversary Corvette
It shouldn't be too hard to port a C application. I don't know what kind of application it is. But I guess a great amount of the code doesn't need to be ported.
Search for those parts of the code which are platform-dependent and find out how the several platforms handle those functionalities. Perhaps some libraries are available for other platforms too.
I think it's a good idea to organise the code in such a way that platform-dependent code can be put apart. When going to a different platform you then only need to turn some compiler switches on or off.
ANSI ISO IEC 9899 is the current C standard. You could get a copy of this e-document. I just plan on using .NET though for my cross platform work, because than I can use graphics libraries but when you think of porting the basic definition it shouldn't be too difficult, you have to keep in mind the vendors implimentation (compiler) and like I mentioned API's. Without an execution environment like .NET or Java Virtual Machine, you will have major problems porting sophisticated applications.
Hmm... C99 is hardly a "basic definition." It defines the whole C language. It dictates how C acts and how compilers should act. C99 is ANSI C, so I find it strange that you say C99 or ANSI C. Kind of like saying a cat or a feline isn't it?The C language definition is supported on most every system though, but this is just the basic definition C99 or ANSI C.
There are two really good ways I can think of to make your code more portable/ easier to port. Actually 3, but one only works in best case situations. You could do like Garfield said and use conditional compilation. It would have helped maybe more if he explained what that was, so I am going to assume he meant using compiler directives like #if and #ifdef to tell the compiler how to compile your code depending on what system/compiler you are compiling for. Secondly you could use an abstaction layer. Take all the code that is not ANSI portable and put them into functions in a separate file, say foo.c. Make the corresponding foo.h file with function prototypes, then make a separate foo.c file for ever system/compiler you wish to port your program to. Then all you have to do is include the correct .c file in your project and you are off to the races. The .h file should work for any system if you did it right because all it should have is prototypes of the functions, which if you don't want to have to play around with your source code too much should all have the same prototypes. This is only a small description of abstraction, but I am sure you can find a more indepth walk-thru or tutorial. The final option is to, if possible, write it all in ANSI compliant C, then you are guaranteed that it will be 100% portable to any system with an ANSI C compiler... which I can't think of one system without one... ok I guess the commador 64...
one fish two fish
red fish blue fish
>The final option is to, if possible, write it all in ANSI compliant C, then you are guaranteed that it will be 100% portable to any system with an ANSI C compiler
This is rather difficult, assuming you've made the distinction between conforming and strictly conforming when it comes to following the ANSI/ISO guidlines.
Strictly conforming is as follows:
- The program only uses features specified in the ANSI/ISO standard
- The program doesn't exceed any implementation defined limit.
- The program has no output that depends on implementation defined, unspecified, or undefined features.
A strictly conforming program is maximally portable and has the same output on any system.
A conforming program can depend on nonportable features. Which means that it's conforming in the specific implementation but could be non-conforming on another compiler. For the most part programs are conforming more often than strictly conforming.
The goal of course is to be strictly conforming and still manage to get the program to do what you want. This post is really irrelevant though because it doesn't matter when you get down to it as strictly conforming and conforming are considered the same in most circles. I just felt the need to elaborate a bit.
-Prelude
My best code is written with the delete key.
I meant strictly conforming... anyways I said that it wasn't the easiest or necessarily the desired method of approach, I was only listing it amoung the options. Good point though...
one fish two fish
red fish blue fish
I don't think you will get far with this. As far as I've seen only *NIX follows the ANSI or C99 standard. I think that the only way to accomplish fully portable code is to use an intermediate language and build a common language runtime execution environment.
You havn't looked very hard. Borland, DGJPP(which uses gcc for windows/dos programs), MSVC++, and a few others all have options you can flag to get full ANSI Compliance.... it is only as simple as reading your documentation....
one fish two fish
red fish blue fish