How would I achieve this dynamic_cast?

This is a discussion on How would I achieve this dynamic_cast? within the C++ Programming forums, part of the General Programming Boards category; When using the Windows API, I usually use the types specified by the functions like DWORD... even though I think ...

  1. #16
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    When using the Windows API, I usually use the types specified by the functions like DWORD... even though I think those typedefs are kind of stupid.
    It has a few advantages, such as:
    - Easier to match the types passed with the parameter types in MSDN, rather than mentally converting all the Windows types into primative types.
    - It makes it look more consistent.
    - If Microsoft ever lost their minds and decided to change the typedefs to something else (DWORD = unsigned long long instead of unsigned int, for example), then you don't have to worry about changing all the types you use in your code.

  2. #17
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    You mean, like WPARAM, LPARAM and LRESULT are 64 bits in 64-bit systems? And WPARAM was just 16 bits in 16-bit systems?
    Or you can go the other way round - what happens if you use a long in the 32-bit system and then try to compile it with a 64-bit MinGW GCC?

    There's a reason for these typedefs - most of them, anyway. INT, LONG and its friends are just stupid.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #18
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,536
    Quote Originally Posted by cpjust View Post
    When using the Windows API, I usually use the types specified by the functions like DWORD... even though I think those typedefs are kind of stupid.
    It has a few advantages, such as:
    - Easier to match the types passed with the parameter types in MSDN, rather than mentally converting all the Windows types into primative types.
    - It makes it look more consistent.
    - If Microsoft ever lost their minds and decided to change the typedefs to something else (DWORD = unsigned long long instead of unsigned int, for example), then you don't have to worry about changing all the types you use in your code.
    I do use them, but I don't use LPCSTR and the like. Especially pointer typedefs are stupid.
    The rest I have no quarrels about. I tend to match type simply for the reason you specify.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 10-31-2008, 01:26 PM
  2. Best way to achieve this
    By cloudy in forum Networking/Device Communication
    Replies: 1
    Last Post: 09-06-2006, 07:23 PM
  3. Replies: 3
    Last Post: 09-11-2005, 10:13 AM
  4. The more intelligent risks you take in life, the more you'll achieve
    By Terrance in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 05-20-2003, 05:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21