I have never been entirely clear whether a clear distinction
between type-conversion and type-coercion in the C language.
What I know is, I have written many programs that appear to
work as intended when I adopt the following practice:

   a = typename(b);     // convert
   a = (typename)b;     // coerce
//
// just to be clear what I mean by "convert" and "coerce":
//
// convert = convert the value of the variable or expression b
//                  into the format of the data-type "typename", and
//                  then assign that value to variable a per normal
practice.
//
// coerce = pretend the bits stored at the address of variable b
//                correctly represent a value in the format of data-type
//                "typename", and then assign that value to variable a
//                per normal practice.

Unfortunately, my C code written in this way does not compile
on Linux in the eclipse IDE (i assume with the GCC C compiler).

What is my best strategy for:
   1: making all these lines of source-code compile "as is"
   2: change all these lines of source-code and "stay portable"
   3: change all these lines of source-code and break portability

Obviously #3 is only relevant if #1 and #2 cannot be arranged.

Thanks in advance for information and answers.
-- 
View this message in context: 
http://www.nabble.com/syntax-of-conversion-versus-coersion-in-C-----for-various-OS-tp15113482p15113482.html
Sent from the C-prog mailing list archive at Nabble.com.

Reply via email to