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. Other Discussions
  3. The Weird and The Wonderful
  4. If, for some weird reason, you _have_ to use Hungarian in .NET, at least use it properly

If, for some weird reason, you _have_ to use Hungarian in .NET, at least use it properly

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpcom
31 Posts 12 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.
  • J John R Shaw

    Actually no! Long pointers are not used any more and where used to overcome the limitations of PC memory access. The PC was limited to accessing only 64k, minus a few bytes for the systems use, so that was the max you could allocate with standard C (malloc). A normal pointer was only 16 bits, and a long pointer was a 32 bit pointer which required the compiler to generate code that allowed you to access more that 64k. Microsoft had the keyword ‘_far’ which told the compiler to make the pointer 32 bits instead of 16 bits and generate the required code. When Windows 95 came along and VC6 came out the ‘_far’ keyword was no longer supported, because it was not longer needed. All the ‘lp’ references in the code no longer mattered because all the pointers where now the same size, but if your previous code used the macro definitions like ‘LPSTR’ then it would still compile without error because the macros had been changed. If you had used the keyword ‘_far’ in any of your code, then you had to go in and remove it so you could compile the same code on the new compiler. That is pretty much it, ‘lp’ means ‘p’ now days.

    INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

    A Offline
    A Offline
    Arun Immanuel
    wrote on last edited by
    #20

    Thank you very much for your reply. But, in C Language, how to access the memory 0xb8000000 which is the memory address for VDU. Similarly , how to execute the POST function located at 0xffff000 without far pointer?

    Regards, Arun Kumar.A

    J 1 Reply Last reply
    0
    • J John R Shaw

      What really bugs me some times is that even though the C and C++ languages are standardized the size of the types are not. That is even the size of ‘char’ is not guaranteed to be a byte, at least that is what Bjarne Stroustrup says and he should know.

      INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #21

      Thank god for sizeof I say.

      Deja View - the feeling that you've seen this post before.

      J 1 Reply Last reply
      0
      • P Pete OHanlon

        Thank god for sizeof I say.

        Deja View - the feeling that you've seen this post before.

        J Offline
        J Offline
        John R Shaw
        wrote on last edited by
        #22

        You do know that ‘sizeof’ returns a number based on the ‘char’ size don’t you. Therefore if the character size was 16 bits then ‘sizeof(char)’ would still be 1 and not the number of bytes. Isn’t non-specific specifications wonderful. :laugh:

        INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

        1 Reply Last reply
        0
        • A Arun Immanuel

          Thank you very much for your reply. But, in C Language, how to access the memory 0xb8000000 which is the memory address for VDU. Similarly , how to execute the POST function located at 0xffff000 without far pointer?

          Regards, Arun Kumar.A

          J Offline
          J Offline
          John R Shaw
          wrote on last edited by
          #23

          Now days: unsigned char* p = (unsigned char*)0xB8000000L; Old days: unsigned char _far* p = (unsigned char _far*)0xB8000000L; Used to do stuff like that all the time to directly access video memory and other hardware, but modern operating systems do not allow that any more. Accept for older code, which it places in a sandbox (its own processing space) so it can keep an eye on it, and even then it may not allow it. Direct access now requires a driver down at ring 0 to access hardware directly, but there is usually something like DirectX that does it for you. Note that both the addresses you mentioned are 32 bit and are therefore just ordinary pointers on a 32 bit machine.

          INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

          A 1 Reply Last reply
          0
          • J John R Shaw

            Now days: unsigned char* p = (unsigned char*)0xB8000000L; Old days: unsigned char _far* p = (unsigned char _far*)0xB8000000L; Used to do stuff like that all the time to directly access video memory and other hardware, but modern operating systems do not allow that any more. Accept for older code, which it places in a sandbox (its own processing space) so it can keep an eye on it, and even then it may not allow it. Direct access now requires a driver down at ring 0 to access hardware directly, but there is usually something like DirectX that does it for you. Note that both the addresses you mentioned are 32 bit and are therefore just ordinary pointers on a 32 bit machine.

            INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

            A Offline
            A Offline
            Arun Immanuel
            wrote on last edited by
            #24

            Thank you very much. :):):)

            Regards, Arun Kumar.A

            1 Reply Last reply
            0
            • J John R Shaw

              LOL! Sorry I tend not to notice the ‘.Net’ reference when looking at code that appears to be C or C++. Try that same logic in C or C++ and you will see it does not apply. When computers used 16 bit words an ‘int’ was supposed to be 16 bits as per language specifications (but actually it depended on the compiler). When they changed to 32 bit words (size of register) and new compilers came out, then ‘int’ became 32 bits per language specifications, which made it the same as a long. I do not know what artificial limits C# uses, but C and C++ uses register size and the compiler vendor sets the limits according to the standard. Any code you develop should be archived along with a copy of the compiler (environment) and the associated libraries, so that it can be recreated without having to modify it.

              INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

              R Offline
              R Offline
              Rob Grainger
              wrote on last edited by
              #25

              Sorry to point this out, but that's by convention but not by the standard. All the standard states is that sizeof(short) <= sizeof(int) <= sizeof(long). Most implementations, however, have adopted the convention that an int is register size. However, a 32-bit compiler could choose short as 16-bit, int as 32-bit and long as 64-bit without breaking the standard, it just may not interoperate with code from other compilers very well. Similarly char is a character - this could be 8-bit or 16-bit. In C++, they tend (I've never seen an exception) to be 8-bit, but the standard doesn't actually rule it out.

              R J 2 Replies Last reply
              0
              • S szukuro

                OK, I should've used the joke icon. If you take a look at my profile, I'm from Hungary. The joke was based upon the fact that Hungarian is not the same as Hungarian Notation.

                S Offline
                S Offline
                Stick
                wrote on last edited by
                #26

                I got it. =) I knew right away you had to be from Hungary, with that sense of humor, haha.

                1 Reply Last reply
                0
                • R Rob Grainger

                  Sorry to point this out, but that's by convention but not by the standard. All the standard states is that sizeof(short) <= sizeof(int) <= sizeof(long). Most implementations, however, have adopted the convention that an int is register size. However, a 32-bit compiler could choose short as 16-bit, int as 32-bit and long as 64-bit without breaking the standard, it just may not interoperate with code from other compilers very well. Similarly char is a character - this could be 8-bit or 16-bit. In C++, they tend (I've never seen an exception) to be 8-bit, but the standard doesn't actually rule it out.

                  R Offline
                  R Offline
                  ricecake
                  wrote on last edited by
                  #27

                  Rob Grainger wrote:

                  Similarly char is a character - this could be 8-bit or 16-bit. In C++, they tend (I've never seen an exception) to be 8-bit, but the standard doesn't actually rule it out.

                  Some DSPs use 16-bit chars. Also, some weird machines (maybe it was the PDP-11?) use 9-bit chars. The standard just says that char is at least 8 bits.

                  -- Marcus Kwok

                  J 1 Reply Last reply
                  0
                  • J John R Shaw

                    What really bugs me some times is that even though the C and C++ languages are standardized the size of the types are not. That is even the size of ‘char’ is not guaranteed to be a byte, at least that is what Bjarne Stroustrup says and he should know.

                    INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                    R Offline
                    R Offline
                    ricecake
                    wrote on last edited by
                    #28

                    char is 1 byte, by definition. However, this byte may not be one octet (8 bits), so that the system uses e.g. 9-bit (rare) or 16-bit (used on some DSPs) "bytes".

                    -- Marcus Kwok

                    1 Reply Last reply
                    0
                    • V Vikram A Punathambekar

                      Seen in production code

                      int intTrStatusCnt = 0;
                      long intMaxTrLogID = 0;
                      long intMaxTrStatusID = 0;

                      Cheers, Vıkram.


                      Déjà moo - The feeling that you've seen this bull before. Join the CP group at NationStates. Password: byalmightybob

                      V Offline
                      V Offline
                      Vasudevan Deepak Kumar
                      wrote on last edited by
                      #29

                      The rule is best when used in spirit in more degree and emphasis than in letter. There used to be one lesson in my tenth standard English book "All about the dog". I forgot the author. It used to emphasize this letter vs spirit.

                      Vasudevan Deepak Kumar Personal Homepage Tech Gossips

                      1 Reply Last reply
                      0
                      • R Rob Grainger

                        Sorry to point this out, but that's by convention but not by the standard. All the standard states is that sizeof(short) <= sizeof(int) <= sizeof(long). Most implementations, however, have adopted the convention that an int is register size. However, a 32-bit compiler could choose short as 16-bit, int as 32-bit and long as 64-bit without breaking the standard, it just may not interoperate with code from other compilers very well. Similarly char is a character - this could be 8-bit or 16-bit. In C++, they tend (I've never seen an exception) to be 8-bit, but the standard doesn't actually rule it out.

                        J Offline
                        J Offline
                        John R Shaw
                        wrote on last edited by
                        #30

                        I did not look it up, but at one time the C standard stated that an int was the size of a machine word and a short was 16-bits. I could be wrong, since it has be some years since I read it.

                        INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                        1 Reply Last reply
                        0
                        • R ricecake

                          Rob Grainger wrote:

                          Similarly char is a character - this could be 8-bit or 16-bit. In C++, they tend (I've never seen an exception) to be 8-bit, but the standard doesn't actually rule it out.

                          Some DSPs use 16-bit chars. Also, some weird machines (maybe it was the PDP-11?) use 9-bit chars. The standard just says that char is at least 8 bits.

                          -- Marcus Kwok

                          J Offline
                          J Offline
                          John R Shaw
                          wrote on last edited by
                          #31

                          Thanks! I can never remember which systems use character sizes other than 8-bits, I just remember there are a few out there. Of course I know nothing more than that or even what language compilers support those systems.

                          INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                          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