iSeries C/C++ Technical Discussion Mailing ListMailing list archive for c400-l at midrange.comRe: Basic c question again - type casting- June 13, 2008 Well said! Bobhttp://feeds.midrange.com/~r/c400-l/~3/311182347/msg00031.html Re: Basic c question again - type casting- June 13, 2008 As a general rule, you should aim to code without any casts. Sometimes they are necessary, but you should do everything you can to avoid them. As a hard-and-fast rule: Never code a cast unless you understand _completely_ what the effect will be. You have ...http://feeds.midrange.com/~r/c400-l/~3/311166758/msg00030.html Re: Basic c question again - type casting- June 12, 2008 As a general rule, you should aim to code without any casts. Sometimes they are necessary, but you should do everything you can to avoid them. As a hard-and-fast rule: Never code a cast unless you understand _completely_ what the effect will be. You have ...http://feeds.midrange.com/~r/c400-l/~3/310899884/msg00029.html Re: Basic c question again - type casting- June 12, 2008 What you have done is to tell the compiler "Trust me. I am really giving you a char". Whether it will work depends on whether you have lied to the compiler. We probably can't tell you much on this one without seeing more of the code. C is not the kind of...http://feeds.midrange.com/~r/c400-l/~3/310746242/msg00028.html Re: Basic c question again - type casting- June 12, 2008 Ok. I think I got it. I did below and it compile. Not sure if it will run correctly or not. But at least it compiled :) logECD_STP((char ) &data); I was doing this and compiler is not likely it logECD_STP((char ) &data); -----Original Message----- From:...http://feeds.midrange.com/~r/c400-l/~3/310746243/msg00027.html Re: Basic c question again - type casting- June 12, 2008 What you have above is a function that accepts a pointer to a pointer to a char. This works because the declaration char data; defines a pointer to a char. the & symbol means "the address of", so "&data" means "the address of the variable data". Pointer...http://feeds.midrange.com/~r/c400-l/~3/310746244/msg00026.html Basic c question again - type casting- June 12, 2008 If I've a function like below: void logECD_STP3(const char dataRcv); Below compile and work fine: char data; code that put stuff into data . . . logECD_STP(&data); How do I do the same thing if I've UAM data; code that put stuff into data . . ....http://feeds.midrange.com/~r/c400-l/~3/310746245/msg00025.html Re: basic c question about char- June 12, 2008 You can do this easily enough in RPG using the %BITxxx functions, the MI built-ins, or by writing a procedure to mask TESTB usage. Basic bit operations (set, test, mask) are fairly easy in RPG. It's only bit-shifting that's a bit harder (haha). Otherwise ...http://feeds.midrange.com/~r/c400-l/~3/310746246/msg00024.html Re: CZM0342 "" detected in comment.- June 12, 2008 I see you found the cause but you do at least need to investigate this sort of error. If it really is embedded in a comment--that is inside a properly closed comment--then it can be ignored but better to remove the cause of the warning. The reason you nee...http://feeds.midrange.com/~r/c400-l/~3/310746247/msg00023.html Re: CZM0342 "" detected in comment.- June 12, 2008 Never mind. My source file length is too short and when I copy the program from production it cut of part of the code. thanks -----Original Message----- From: c400-l-bounces+lim.hock-chai=usamobility.comxxxxxxxxxxxx mailto:c400-l-bounces+lim.hock-chai=us...http://feeds.midrange.com/~r/c400-l/~3/310746248/msg00022.html |