Standard integer types vs <stdint.h> types

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Malcolm McLean

    Re: Standard integer types vs &lt;stdint.h&gt ; types


    "Ben Bacarisse" <ben.usenet@bsb .me.ukwrote in message
    Malcolm had stated that arrays are the only "basic data structures"
    (with support in the language). They too could be called compound.
    >
    In chemistry we'd call structs "compounds" and arrays "polymers".

    --
    Free games and programming goodies.


    Comment

    • Army1987

      Re: Standard integer types vs &lt;stdint.h&gt ; types

      Malcolm McLean wrote:
      That's a totally untypical program. Most C programs use arrays very heavily.
      In fact it is the only basic data structure that has direct language
      support.
      Sometimes in older C programs you see pointer notation used where array
      dereferencing would be clearer, I'll grant you. That's technically an
      exception to my point, even though an integer will be used to count down the
      travelling pointer.
      I can't see any reason why a program using:
      for (p = a; p < a + n; p++) {
      frobnicate(*a);
      }
      is any more "untypical" or less "clear" than
      for (i = 0; i < n; i++) {
      frobnicate(a[i]);
      }

      --
      Army1987 (Replace "NOSPAM" with "email")

      Comment

      • Malcolm McLean

        Re: Standard integer types vs &lt;stdint.h&gt ; types

        "Army1987" <army1987@NOSPA M.itwrote in message
        Malcolm McLean wrote:
        >
        >That's a totally untypical program. Most C programs use arrays very
        >heavily.
        >In fact it is the only basic data structure that has direct language
        >support.
        >Sometimes in older C programs you see pointer notation used where array
        >dereferencin g would be clearer, I'll grant you. That's technically an
        >exception to my point, even though an integer will be used to count down
        >the
        >travelling pointer.
        >
        I can't see any reason why a program using:
        for (p = a; p < a + n; p++) {
        frobnicate(*a);
        }
        is any more "untypical" or less "clear" than
        for (i = 0; i < n; i++) {
        frobnicate(a[i]);
        }
        >
        You've answered your own question.
        Example 1 is incorrect.

        --
        Free games and programming goodies.


        Comment

        • Richard Tobin

          Re: Standard integer types vs &lt;stdint.h&gt ; types

          In article <1dOdnRWKN5ks9g ranZ2dneKdnZydn Z2d@bt.com>,
          Malcolm McLean <regniztar@btin ternet.comwrote :
          >I can't see any reason why a program using:
          >for (p = a; p < a + n; p++) {
          > frobnicate(*a);
          >}
          >is any more "untypical" or less "clear" than
          >for (i = 0; i < n; i++) {
          > frobnicate(a[i]);
          >}
          >You've answered your own question.
          >Example 1 is incorrect.
          I don't think a typo in an example proves much. He could have typed,
          say, a[n] in the second case and it would have been just as wrong.

          -- Richard
          --
          :wq

          Comment

          • Malcolm McLean

            Re: Standard integer types vs &lt;stdint.h&gt ; types


            "Paul Hsieh" <websnarf@gmail .comwrote in message
            On Jan 22, 4:10 am, "Bart C" <b...@freeuk.co mwrote:
            >"Malcolm McLean" <regniz...@btin ternet.comwrote in message
            >
            I think that's what Malcolm's original point was. Structs, pointers
            and arrays are really just the building blocks for real data
            structures.
            >
            Unfortunately, a single flat record sequence (i.e., a struct) is also
            a data structure, so I don't think his distinction is precise enough.
            >
            You could argue it is. A floating point number is also a "data structure" on
            that definition, since it has a flag, an exponent, and a mantissa.

            In general terms, by "data structure" we don't mean "a type of struct". We
            means "several similar items linked together in some way".

            --
            Free games and programming goodies.


            Comment

            • Army1987

              Re: Standard integer types vs &lt;stdint.h&gt ; types

              jacob navia wrote:
              I mean if I have some data (like 45 000) how the hell I am supposed to
              know if the implementation supports that unless I use can hold that?
              I cannot parse the second half of the sentence, but what's wrong with
              `long n = 45000; ` or `unsigned n = 45000; `?



              --
              Army1987 (Replace "NOSPAM" with "email")

              Comment

              • Flash Gordon

                Re: Standard integer types vs &lt;stdint.h&gt ; types

                Malcolm McLean wrote, On 24/01/08 13:12:
                >
                "Paul Hsieh" <websnarf@gmail .comwrote in message
                >On Jan 22, 4:10 am, "Bart C" <b...@freeuk.co mwrote:
                >>"Malcolm McLean" <regniz...@btin ternet.comwrote in message
                >>
                >I think that's what Malcolm's original point was. Structs, pointers
                >and arrays are really just the building blocks for real data
                >structures.
                >>
                >Unfortunatel y, a single flat record sequence (i.e., a struct) is also
                >a data structure, so I don't think his distinction is precise enough.
                >>
                You could argue it is. A floating point number is also a "data
                structure" on that definition, since it has a flag, an exponent, and a
                mantissa.
                As I pointed out else-thread some lecture notes refer to integer types
                as basic data structures.
                In general terms, by "data structure" we don't mean "a type of struct".
                We means "several similar items linked together in some way".
                A data structure can link a number of dissimilar items together in some
                way. If you want an example that is more complex than a C struct then
                look at relational databases, specifically joins.

                In any case, as there is more than one possible definition of what
                qualifies as a "basic data structure" you cannot say what support C has
                for them unless you first define what you mean by "basic data structure".
                --
                Flash Gordon

                Comment

                • Chris Hills

                  Re: Standard integer types vs &lt;stdint.h&gt ; types

                  In article <pMCdnYu-u61U8Q3anZ2dnUV Z8sSrnZ2d@bt.co m>, Malcolm McLean
                  <regniztar@btin ternet.comwrite s
                  >My own view is that you should be able to stick to char for characters
                  >and int for integers, in almost every situation. However this is only
                  >tenable if you can use int as both an arbitrary array index and a fast
                  >type.
                  Signed and unsigned char are integer types.
                  Plain char is a character type (and the signed/unsigned is
                  implementation dependant)

                  there are more 8 bit MCU out there than anything else. They usually use
                  signed/unsigned char as their base type for most things.
                  --
                  \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
                  \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
                  /\/\/ chris@phaedsys. org www.phaedsys.org \/\/\
                  \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



                  Comment

                  • Chris Hills

                    Re: Standard integer types vs &lt;stdint.h&gt ; types

                    In article <fmrubv$8k2$1@r umours.uwaterlo o.ca>,
                    dj3vande@csclub .uwaterloo.ca.i nvalid writes
                    >In article <6cSdnXRc5KFyNw 3anZ2dnUVZ8rOdn Z2d@bt.com>,
                    >Richard Heathfield <rjh@see.sig.in validwrote:
                    >>Flash Gordon said:
                    >
                    >>Personally I don't find underscores in names
                    >>a problem for scanning, especially once I have learnt the patterns.
                    >>
                    >>Is ugliness a problem? I guess ugliness is in the eye of the beholder.
                    >
                    >For exact-width types, I actually lean toward considering ugliness a
                    >Good Thing.
                    >
                    >Most people who think they need exact-width types are wrong, and making
                    >them as ugly and inconvenient as possible discourages their use (which
                    >on the whole is a Good Thing); but when you actually do need them (I've
                    On embedded systems when you interface to hardware, do bit manipulation
                    etc


                    --
                    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
                    \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
                    /\/\/ chris@phaedsys. org www.phaedsys.org \/\/\
                    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



                    Comment

                    • Chris Hills

                      Re: Standard integer types vs &lt;stdint.h&gt ; types

                      In article <Jc2dnZ77WbV8Xg 3anZ2dnUVZ8qOkn Z2d@bt.com>, Malcolm McLean
                      <regniztar@btin ternet.comwrite s
                      >
                      >"Flash Gordon" <spam@flash-gordon.me.ukwro te in message
                      >See above, the types you want have been supported for a long time. If
                      >>you don't like the spelling you can typedef them to something else.
                      >>
                      >bool breaks libraries.
                      >
                      >If ANSI decides that "s64" shall be the name of a new type, that's
                      >fine.
                      Only if they get it past the other 30-40 nations defining C
                      >If I define it myself, either the whole world adopts my convention,
                      >which is to say I have usurrped ANSI / ISO,
                      You could get them to adopt it.
                      >it is a nuisance to everybody trying to call or read my code.
                      No change there then :-))))
                      --
                      \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
                      \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
                      /\/\/ chris@phaedsys. org www.phaedsys.org \/\/\
                      \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



                      Comment

                      • Chris Hills

                        Re: Standard integer types vs &lt;stdint.h&gt ; types

                        In article <5vdln5F1k2pn3U 8@mid.individua l.net>, Ian Collins
                        <ian-news@hotmail.co mwrites
                        >CBFalconer wrote:
                        >Ian Collins wrote:
                        >>Richard Heathfield wrote:
                        >>>
                        >.... snip ...
                        >>>Let me ask you something - do you ignore 1024 bit types if they
                        >>>are available? How about ignoring 131072 bit types if they are
                        >>>available? What about 1048576 bit types?
                        >>Well the platforms I work on are either POSIX compliant, or I use
                        >>a POSIX wrapper over the native API, which provides stdint.h.
                        >>
                        >The last time I looked the C standard had absolutely no reference
                        >to POSIX. If this was comp.os.posix your comment would have a good
                        >chance of being on topic.
                        >>
                        >I take it back. It shows up in the bibliography. Once. Still OT.
                        >>
                        >Does every word posted here have to be in the ISO C standard to meet
                        >with your approval? Read what I was answering.
                        Ignore him.

                        There are a small band of zealots on c.l.c who use the C standard like
                        fundamental Christians read the Bible.



                        --
                        \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
                        \/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
                        /\/\/ chris@phaedsys. org www.phaedsys.org \/\/\
                        \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



                        Comment

                        Working...