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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/28/08 07:44
Read: times


 
#157811 - Portability C
Responding to: ???'s previous message
A benefit of using a high level language is that it provides a uniform abstraction from implementation dependencies introduced by hardware differences. When you have to get 'down and dirty', the abstraction gets in the way, and things get ugly. As this situation is inevitable in embedded programming, I think the best guideline is to make sure that all the non-portable bits are lumped together in well documented modules.

When binary data is transmitted between systems, the data format needs to be considered. For floats, IEEE754 is a godsend, I would seriously consider boycotting any compiler that does not use it. The problem is deeper than just floats though, because the endianness of the two systems may differ.

I usually use the union method for these sorts of problems, because with suitable #defines I can also make the code portable with respect to endianness.

List of 10 messages in thread
TopicAuthorDate
silly C question            01/01/70 00:00      
   *(float*)&time            01/01/70 00:00      
      Thanks!!!            01/01/70 00:00      
         Here's one without wild casting:            01/01/70 00:00      
            Nothing wild            01/01/70 00:00      
               union misuse            01/01/70 00:00      
                  Not hiding cast            01/01/70 00:00      
                  Programmer knowledge required.            01/01/70 00:00      
                     Hiding of portability issue            01/01/70 00:00      
                     Portability C            01/01/70 00:00      

Back to Subject List