Loading ...
Sorry, an error occurred while loading the content.

Is char signed or unsigned..??

Expand Messages
  • Rakesh Kumar
    Hi.. what is the difference between plain char and signed char? How does below two warnings are related to these distinct data types and how to get rid of
    Message 1 of 5 , Nov 13, 2010
    • 0 Attachment
      Hi..

      what is the difference between plain char and signed char?

      How does below two warnings are related to these distinct data types and how to get rid of these warnings?

      1. pointer targets in initialization differ in signedness

      2. pointer targets don't differ in signedness

      Also is it going to have any impact on instruction set generation..???

      Regards,


    • Gala Dragos
      Virtually none ! signed char definitely defines a char variable with a sign ! unsigned char definitely creates a char variable without a sign ! Plain char is
      Message 2 of 5 , Nov 13, 2010
      • 0 Attachment
        Virtually none !

        signed char definitely defines a char variable with a sign !
        unsigned char definitely creates a char variable without a sign !

        Plain char is treated as signed char in 99% of the cases, but it can be changed to either signed or unsigned at compilation time by the compiler itself ! GCC has a directive to treat all chars as unsigned chars (very useful in 8 bit systems).

        Some warnings do not impede program functions, but every compiler has it's quirks !

        Check your compiler documentation !
         
        ----------------------------------------------------------------------------------------------------------------------------------

        . Microsoft broke the Volkswagen world record: Volkswagen only made 22 million bugs!


        . It is time for us to stand and cheer for the doer, the achiever, the one who recognizes the challenge and does something about it.
        -Vince Lombardi


        . Everybody can learn how to make kids, but not everyone can raise them right!



        From: Rakesh Kumar <rakesh.kumar58@...>
        To: TMS470 <TMS470_ARM@yahoogroups.com>
        Sent: Sat, November 13, 2010 7:00:47 PM
        Subject: [TMS470_ARM] Is char signed or unsigned..??

         

        Hi..

        what is the difference between plain char and signed char?

        How does below two warnings are related to these distinct data types and how to get rid of these warnings?

        1. pointer targets in initialization differ in signedness

        2. pointer targets don't differ in signedness

        Also is it going to have any impact on instruction set generation..???

        Regards,



      • Rick Collins
        You should be type casting your assignments rather than letting the compiler guess about what you want to do. Once to tell the compiler what you want, it will
        Message 3 of 5 , Nov 13, 2010
        • 0 Attachment
          You should be type casting your assignments rather than letting the compiler guess about what you want to do.  Once to tell the compiler what you want, it will stop warning you that it is making assumptions. 

          Rick


          At 12:00 PM 11/13/2010, you wrote:
           

          Hi..

          what is the difference between plain char and signed char?

          How does below two warnings are related to these distinct data types and how to get rid of these warnings?

          1. pointer targets in initialization differ in signedness

          2. pointer targets don't differ in signedness

          Also is it going to have any impact on instruction set generation..???

          Regards,


        • Rakesh Kumar
          Hi.. Sorry for the delayed reply mail. Actually i am getting the warning (pointer targets in initialization differ in signedness)for below code: static const
          Message 4 of 5 , Nov 22, 2010
          • 0 Attachment
            Hi..

            Sorry for the delayed reply mail.

            Actually i am getting the warning (pointer targets in initialization differ in signedness)for below code:
            static const signed char *arr[1] =
            {
               "kpk"
            }

            Please let me know how to get rid of this..

            Regards,



            --- On Sat, 11/13/10, Gala Dragos <gala_dragos@...> wrote:

            From: Gala Dragos <gala_dragos@...>
            Subject: Re: [TMS470_ARM] Is char signed or unsigned..??
            To: TMS470_ARM@yahoogroups.com
            Date: Saturday, November 13, 2010, 7:12 PM

             

            Virtually none !

            signed char definitely defines a char variable with a sign !
            unsigned char definitely creates a char variable without a sign !

            Plain char is treated as signed char in 99% of the cases, but it can be changed to either signed or unsigned at compilation time by the compiler itself ! GCC has a directive to treat all chars as unsigned chars (very useful in 8 bit systems).

            Some warnings do not impede program functions, but every compiler has it's quirks !

            Check your compiler documentation !
             
            ----------------------------------------------------------------------------------------------------------------------------------

            . Microsoft broke the Volkswagen world record: Volkswagen only made 22 million bugs!


            . It is time for us to stand and cheer for the doer, the achiever, the one who recognizes the challenge and does something about it.
            -Vince Lombardi


            . Everybody can learn how to make kids, but not everyone can raise them right!



            From: Rakesh Kumar <rakesh.kumar58@...>
            To: TMS470 <TMS470_ARM@yahoogroups.com>
            Sent: Sat, November 13, 2010 7:00:47 PM
            Subject: [TMS470_ARM] Is char signed or unsigned..??

             

            Hi..

            what is the difference between plain char and signed char?

            How does below two warnings are related to these distinct data types and how to get rid of these warnings?

            1. pointer targets in initialization differ in signedness

            2. pointer targets don't differ in signedness

            Also is it going to have any impact on instruction set generation..???

            Regards,




          • Gala Dragos
            Probably the ascii translation of kpk is treated as unsigned char. Secondly you have three elements not 1 so you need to write arr[3]. Also you do not create
            Message 5 of 5 , Nov 24, 2010
            • 0 Attachment
              Probably the ascii translation of "kpk" is treated as unsigned char. Secondly you have three elements not 1 so you need to write arr[3]. Also you do not create a pointer, you create an array ! The array can be used as a pointer, without the *. This is simple C syntax.

              Try this:

              static const signed char arr[3] =
              {
                 "kpk"
              }
               
              ----------------------------------------------------------------------------------------------------------------------------------

              . Microsoft broke the Volkswagen world record: Volkswagen only made 22 million bugs!


              . It is time for us to stand and cheer for the doer, the achiever, the one who recognizes the challenge and does something about it.
              -Vince Lombardi


              . Everybody can learn how to make kids, but not everyone can raise them right!



              From: Rakesh Kumar <rakesh.kumar58@...>
              To: TMS470_ARM@yahoogroups.com
              Sent: Mon, November 22, 2010 8:07:18 PM
              Subject: Re: [TMS470_ARM] Is char signed or unsigned..??

               

              Hi..

              Sorry for the delayed reply mail.

              Actually i am getting the warning (pointer targets in initialization differ in signedness)for below code:
              static const signed char *arr[1] =
              {
                 "kpk"
              }

              Please let me know how to get rid of this..

              Regards,



              --- On Sat, 11/13/10, Gala Dragos <gala_dragos@...> wrote:

              From: Gala Dragos <gala_dragos@...>
              Subject: Re: [TMS470_ARM] Is char signed or unsigned..??
              To: TMS470_ARM@yahoogroups.com
              Date: Saturday, November 13, 2010, 7:12 PM

               

              Virtually none !

              signed char definitely defines a char variable with a sign !
              unsigned char definitely creates a char variable without a sign !

              Plain char is treated as signed char in 99% of the cases, but it can be changed to either signed or unsigned at compilation time by the compiler itself ! GCC has a directive to treat all chars as unsigned chars (very useful in 8 bit systems).

              Some warnings do not impede program functions, but every compiler has it's quirks !

              Check your compiler documentation !
               
              ----------------------------------------------------------------------------------------------------------------------------------

              . Microsoft broke the Volkswagen world record: Volkswagen only made 22 million bugs!


              . It is time for us to stand and cheer for the doer, the achiever, the one who recognizes the challenge and does something about it.
              -Vince Lombardi


              . Everybody can learn how to make kids, but not everyone can raise them right!



              From: Rakesh Kumar <rakesh.kumar58@...>
              To: TMS470 <TMS470_ARM@yahoogroups.com>
              Sent: Sat, November 13, 2010 7:00:47 PM
              Subject: [TMS470_ARM] Is char signed or unsigned..??

               

              Hi..

              what is the difference between plain char and signed char?

              How does below two warnings are related to these distinct data types and how to get rid of these warnings?

              1. pointer targets in initialization differ in signedness

              2. pointer targets don't differ in signedness

              Also is it going to have any impact on instruction set generation..???

              Regards,





            Your message has been successfully submitted and would be delivered to recipients shortly.