Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/04/07 11:41
Read: times


 
#147846 - There are downsides
Responding to: ???'s previous message
Yes. You have it right here.

Not only the code tends to become larger and in most cases a tad slower but also the code itself (the library code) tends to grow a very hairy look.

It is really annoying to try to read some highly portable code which is stuffed up to throat with #ifndef ... #elif and #whatever directives. Unfortunately those are unavoidable if one intents to make portable code. Those are a nightmare to debug....

The trick is to isolate the MCU dependant parts and then design the library in a way that those are supplied by a separate set of source/object code. This way the main logic stays free of #directive fiddlings and the port is easier to adopt to a new MCU.

One example (again) would be the LCD driver library. The MCU dependent parts are those that manipulate the control and the data wires. So there will be a set of functions that do only (and only) that. So we have one function that initializes the wires, another that sets the control wires up/down and yet others that read/write the data. One can even leave those out of the library since these are very simple and code them on the main module (making them public). This way one really does not need a single directive in the "business" code.

List of 20 messages in thread
TopicAuthorDate
How to write portable code            01/01/70 00:00      
   C is a language - not a compiler            01/01/70 00:00      
      PL/M            01/01/70 00:00      
         Have you considered PLM2C?            01/01/70 00:00      
   A good point - often missed            01/01/70 00:00      
   So what's the downside?            01/01/70 00:00      
      Complex code - Libraries            01/01/70 00:00      
         COTS libraries versus inhouse libraries            01/01/70 00:00      
            Hence portability is not such a big issue!            01/01/70 00:00      
      There are downsides            01/01/70 00:00      
         Portability vs. Readability/Maintainability.            01/01/70 00:00      
   who gives a hoot about portability            01/01/70 00:00      
      Portable by BIOS            01/01/70 00:00      
   I give a hoot about portability            01/01/70 00:00      
      I am definitely not arguing against "code reuse"            01/01/70 00:00      
         HAL            01/01/70 00:00      
   Small and easy things that may make Your day            01/01/70 00:00      
   The developer is probably the biggest factor            01/01/70 00:00      
      I may take issue with this one...            01/01/70 00:00      
   general re 'portable code'            01/01/70 00:00      

Back to Subject List