Results 1 to 4 of 4

Thread: longword, cardinal, dword, uint32...

  1. #1
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default longword, cardinal, dword, uint32...

    Aren't they the exact same thing? Why is there a need to create so many alias to represent the same data type?

  2. #2
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Aren't they the exact same thing? Why is there a need to create so many alias to represent the same data type?
    I don't know about pascal but some of those types aren't guaranteed in the C and C++ standard.


    longword is the same as dword. It really is just an alias.
    Dword is an alias for unsigned int.

    however, unsigned int is never guaranteed to be 4 bytes always. The sizeof(int) is actually implementation defined but must be greater than or equal to "2".

    In fact, in the old days, vendors used to define int as 2 bytes on some systems and 4 on others.. sometimes even 8. This meant that you had to manually deal with endianness yourself and hardcode sizes in some places.

    Nowadays, most vendors define int to always be 4 bytes but that doesn't mean old systems don't still exist..

    The only guaranteed type there is "uint32" which in C and C++ is defined as "uint32_t" where the "t" means typedef/alias.
    But the standard guarantees that this type is ALWAYS 4 bytes in size. Never larger; never smaller.

    It is especially useful in very very low level code as well as embedded systems..

    http://en.cppreference.com/w/c/types/integer
    http://en.cppreference.com/w/cpp/types/integer

    But I doubt it has any effect in PS/Lape.. so I don't know why they have that many but if it is the same as in C, then the above is the reason. If I had to really really guess, I'd say these types are mostly used for plugin compatibility..
    Last edited by Brandon; 10-26-2014 at 02:36 PM.
    I am Ggzz..
    Hackintosher

  3. #3
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    so I don't know why they have that many ... I'd say these types are mostly used for plugin compatibility..
    Lape's (integer) basetypes are named IntX and UIntX (IE: Int16 & UInt64), other (integer) types are aliases, and mostly exists for compatibility with PascalScript, as PascalScript does NOT have IntX + UIntX named-types.

    References:
    » Lape -> lputils.pas #49
    » Lape -> lpvartypes.pas #718 (lptypes.pas #150)

    DWord is exported by Simba, and I do not know why.. I guess it's just because it's "standard":
    » https://github.com/MerlijnWajer/Simb...ompile.inc#L83
    Last edited by slacky; 10-26-2014 at 08:45 PM.
    !No priv. messages please

  4. #4
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    i see... thanks for the explanation :)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •