Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Arrrrg. I need to vent off.

Arrrrg. I need to vent off.

Scheduled Pinned Locked Moved The Lounge
helplearning
10 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bamaco2
    wrote on last edited by
    #1

    I know this is not for programming, but imagine my frustration when I discovered a bug that was not reported by my compiler: const uint8 kEdlReplyTimeout = 500; Of course, it does not fit in 8 bit (typedefed uint8) and stupid MetroWerks accepts this silently, until I realize it on my own. Sometimes, I just hate my good old msvc 6.0 compiler, but I got to admit, it doesn't let me down on simple things like that one.

    M 1 Reply Last reply
    0
    • B Bamaco2

      I know this is not for programming, but imagine my frustration when I discovered a bug that was not reported by my compiler: const uint8 kEdlReplyTimeout = 500; Of course, it does not fit in 8 bit (typedefed uint8) and stupid MetroWerks accepts this silently, until I realize it on my own. Sometimes, I just hate my good old msvc 6.0 compiler, but I got to admit, it doesn't let me down on simple things like that one.

      M Offline
      M Offline
      Marc Clifton
      wrote on last edited by
      #2

      Yowzers. That's pretty criminal of a compiler not to complain. One thing though, not that the compiler would know the difference if it's properly def'd, but really: uint8 hmmm. unsigned int, erm, 8 bits. Well, int's arent unsigned usually, and their usually not 8 bits. So as the type definition label, I would get confused too. Maybe "u8" or "byte" would be better. Just my 2c. Marc Microsoft MVP, Visual C# MyXaml MyXaml Blog Hunt The Wumpus RealDevs.Net

      B B 2 Replies Last reply
      0
      • M Marc Clifton

        Yowzers. That's pretty criminal of a compiler not to complain. One thing though, not that the compiler would know the difference if it's properly def'd, but really: uint8 hmmm. unsigned int, erm, 8 bits. Well, int's arent unsigned usually, and their usually not 8 bits. So as the type definition label, I would get confused too. Maybe "u8" or "byte" would be better. Just my 2c. Marc Microsoft MVP, Visual C# MyXaml MyXaml Blog Hunt The Wumpus RealDevs.Net

        B Offline
        B Offline
        Bamaco2
        wrote on last edited by
        #3

        I work with micro controllers, and I tought that cross platform communication is fun with this set of types: int8, int16, int32, int64 uint8, uint16, uint32, uint64. When one reads a class definition, one knows the number of bytes that one is talking about. My own 2c. :)

        J 1 Reply Last reply
        0
        • B Bamaco2

          I work with micro controllers, and I tought that cross platform communication is fun with this set of types: int8, int16, int32, int64 uint8, uint16, uint32, uint64. When one reads a class definition, one knows the number of bytes that one is talking about. My own 2c. :)

          J Offline
          J Offline
          Jon Pawley
          wrote on last edited by
          #4

          > number of bytes that one is talking about. Bits, surely? :suss: Jon

          J 1 Reply Last reply
          0
          • J Jon Pawley

            > number of bytes that one is talking about. Bits, surely? :suss: Jon

            J Offline
            J Offline
            Jorgen Sigvardsson
            wrote on last edited by
            #5

            If you know how many bytes, you implicitly know how many bits. The reverse holds as well, as bits are grouped in bytes (on most MODERN systems - don't even think about shooting me down for this you old VAX hacker or whoever you are reading this. Are you a bearded guy in your 60's Jon? ;)) -- Denn du bist, was du isst! Und ihr wisst, was es ist! Es ist mein Teil...?

            1 Reply Last reply
            0
            • M Marc Clifton

              Yowzers. That's pretty criminal of a compiler not to complain. One thing though, not that the compiler would know the difference if it's properly def'd, but really: uint8 hmmm. unsigned int, erm, 8 bits. Well, int's arent unsigned usually, and their usually not 8 bits. So as the type definition label, I would get confused too. Maybe "u8" or "byte" would be better. Just my 2c. Marc Microsoft MVP, Visual C# MyXaml MyXaml Blog Hunt The Wumpus RealDevs.Net

              B Offline
              B Offline
              berndg
              wrote on last edited by
              #6

              You might expect a warning from a modern compiler maybe, but clearly it is not the compiler, but the ANSI-C specification that needs to face the criminal charges here. The assignment is as legal as assigning +128 to a signed (8 bit) integer, and many other cases. As long as implicit conversion rules allow for the conversion, it's fine as far as the language standard is concerned. Use PC-Lint to find these, and many other, issues!

              M 1 Reply Last reply
              0
              • B berndg

                You might expect a warning from a modern compiler maybe, but clearly it is not the compiler, but the ANSI-C specification that needs to face the criminal charges here. The assignment is as legal as assigning +128 to a signed (8 bit) integer, and many other cases. As long as implicit conversion rules allow for the conversion, it's fine as far as the language standard is concerned. Use PC-Lint to find these, and many other, issues!

                M Offline
                M Offline
                Marc Clifton
                wrote on last edited by
                #7

                berndg wrote: The assignment is as legal Are you sure? 500 doesn't exactly fit into an 8 bit quantity. Marc Microsoft MVP, Visual C# MyXaml MyXaml Blog Hunt The Wumpus RealDevs.Net

                B 1 Reply Last reply
                0
                • M Marc Clifton

                  berndg wrote: The assignment is as legal Are you sure? 500 doesn't exactly fit into an 8 bit quantity. Marc Microsoft MVP, Visual C# MyXaml MyXaml Blog Hunt The Wumpus RealDevs.Net

                  B Offline
                  B Offline
                  berndg
                  wrote on last edited by
                  #8

                  I don't have the time to dig through the ANSI-C papers, but I am pretty sure this is a valid (though unhelpful) C assignment, just like all these: unsigned int a = -2; signed char b = 128; unsigned char c = 500; unsigned short s = -1L;

                  B 1 Reply Last reply
                  0
                  • B berndg

                    I don't have the time to dig through the ANSI-C papers, but I am pretty sure this is a valid (though unhelpful) C assignment, just like all these: unsigned int a = -2; signed char b = 128; unsigned char c = 500; unsigned short s = -1L;

                    B Offline
                    B Offline
                    Bamaco2
                    wrote on last edited by
                    #9

                    But C++ is a type safe language, where C is not (or less so)

                    B 1 Reply Last reply
                    0
                    • B Bamaco2

                      But C++ is a type safe language, where C is not (or less so)

                      B Offline
                      B Offline
                      berndg
                      wrote on last edited by
                      #10

                      No, C++ is not a type-safe language. It has better type-safety as ANSI-C does, but that's the begin and that end of it. Example: int eBool; bool bBool; enum { FALSE, TRUE } eBool; eBool = bBool = eBool = 1u; Where is that type-safe?

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups