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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/06/08 14:27
Read: times


 
#156427 - Use different identifiers for global and auto
Responding to: ???'s previous message
Chris,

Juergen has pointed out the unsigned char trap. Many compilers will barf about comparing an unsigned with " < 0 ". I use uchars as counters, but the trick is to say:

for (count = number; count != 0; count--) ...


Your code used the identifier "my_array" for both global and auto instances. Of course the compiler does not care at all. It will choose the correct variable and the correct scope.

But for the sake of your sanity, it is worth using different names especially if it is an array.

With regular variables it is common to use the same name when factoring a function into sub-functions. But these parameters are sent by value, and the sub-function will not corrupt them.

David.

List of 9 messages in thread
TopicAuthorDate
Compile error using a bubble sort            01/01/70 00:00      
   Is the array 'uchar' or is it 'int'? Do not mix.            01/01/70 00:00      
   argument consistency            01/01/70 00:00      
      I had one error and type mismatch seen            01/01/70 00:00      
         more careful with decrement unsigned char            01/01/70 00:00      
         Use different identifiers for global and auto            01/01/70 00:00      
            Yes I saw the corruption...            01/01/70 00:00      
               You can use any type you like.            01/01/70 00:00      
                  thanks guys....            01/01/70 00:00      

Back to Subject List