Electronic – PIC 16F beginner.. difference in program-syntax when using different compilers

compilerpic

As I mentioned, I have just beginned programming pic16f877a. I can now work with 7 segment displays. At present I am using ccs compiler. Nothing wrong with that. But i prefer to be a compiler independent programmer. So i simultaneously want to work in other compilers like IAR or Hitechc. I want to know whether the "program statement declaration in compilers" other than ccs will be different? Please guide me how to approach this thing. I would welcome all forms of suggestions. Thanks in advance.

Best Answer

That great that you want to be compiler independent! Unfortunately hitech and CCS compilers for the low end PICs use a lot of compiler specific preprocessor declarations, compiler specific pin access routines, and in the case of CCS compiler specific routines for access core functions such as SPI, I2C, ADC and so on.

It is not possible to write your code to be non-compiler specific without a lot of preprocessor #define, #ifdef, #ifndef and so on to get access to specific parts of what each compiler has on offer. This would make your code unreadable.

The best thing you could aim for is to be IDE independent and use something like eclipse, so at least you are using the same IDE. This will result in losing CCS wizards for setting up core functions, but will give you greater flexibility in using the same IDE.

Another thing to consider is that both hitech and CCS do not have (at least in the past) a true c compiler linker and required you to use "#include myfile.c" which I personally despise ... but that is another story.

I have not commented on the IAR compiler as I have only used CCS and hitech. Both worked ok, but I was never really happy with either after migrating across from the Motorola (now freescale) platform and using the metroworks compiler which was more advanced at the time. The IAR compiler looks good but I have never used it.