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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/30/05 17:02
Read: times


 
#90705 - Bend over then...
Responding to: ???'s previous message

this talk of the COMPILER promoting variables from type to type,on its own whim, or becaause of something which may,or may not, be in K+R or ANSI is precisely why I use Pascal.


Is there no ANSI/ISO standard for Pascal?

The situations where promotion in 'C' occur are well defined. I know nothing about Pascal but I'll bet it does something similar.

Don't get the impression that the 'C' compiler just substitutes an int for a char whenever it feels like it - if you do this:

char a;

Then 'a' remains a char for the duration of the program. It's value may be promoted to another type if, for instance, it is passed to a function expecting another type, or when it is the operand of certain operators, or in some conditional statement where overflow is a possibility, etc, but 'a' itself will definitely remain a char. These situations are all ones where it is intuitively the right thing for the compiler to do - if it didn't you'd have a whole lot more people unable to understand why their programs don't just work.


you MIGHT be able to cast it EXPLICITLY, into another variable of another type.


Do you mean you can do this: (sorry, I'll have to do it in pseudo 'C'):
char a;
(int)a; //a is now an integer

or this:

char a;
int b;
b=(int)a; //The value of 'a' is cast to int and copied into b







List of 40 messages in thread
TopicAuthorDate
8051 in C or assembly?            01/01/70 00:00      
   Probably C            01/01/70 00:00      
      Always C            01/01/70 00:00      
      Mostly 'C'            01/01/70 00:00      
      No magic wand            01/01/70 00:00      
      Assembler when?            01/01/70 00:00      
         Shared data problem??            01/01/70 00:00      
            Shared Data Problem            01/01/70 00:00      
               I see            01/01/70 00:00      
                  Sared Data            01/01/70 00:00      
                  addendum            01/01/70 00:00      
                     Shared Data            01/01/70 00:00      
               Knowledge, not language.            01/01/70 00:00      
                  Knowledge            01/01/70 00:00      
                     Knowledge            01/01/70 00:00      
                  Promotion            01/01/70 00:00      
                     Promotion            01/01/70 00:00      
                        Promotion            01/01/70 00:00      
                           Traps for the unwary            01/01/70 00:00      
                              Preaching            01/01/70 00:00      
                                 Ditto            01/01/70 00:00      
                                 red rag....            01/01/70 00:00      
                                    Bend over then...            01/01/70 00:00      
                           hauling assembler            01/01/70 00:00      
                           Clarification            01/01/70 00:00      
                           Keil Allows this to be disabled            01/01/70 00:00      
                              Know your tools            01/01/70 00:00      
                                 It means 8 bit may be 16 bits            01/01/70 00:00      
                  More knowledge!            01/01/70 00:00      
         not really            01/01/70 00:00      
   So which...            01/01/70 00:00      
      Calculations in C            01/01/70 00:00      
         ibid            01/01/70 00:00      
         Not always..            01/01/70 00:00      
            Example            01/01/70 00:00      
   Better??            01/01/70 00:00      
   assembly            01/01/70 00:00      
      YMMV            01/01/70 00:00      
   assembly            01/01/70 00:00      
      Hitting the Wall            01/01/70 00:00      

Back to Subject List