typedef

This is a discussion on typedef within the C Programming forums, part of the General Programming Boards category; I'm know the basic typedef usage: typedef unsigned int * INT; This makes INT an alias for a pointer to ...

  1. #1
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784

    typedef

    I'm know the basic typedef usage:

    typedef unsigned int * INT;

    This makes INT an alias for a pointer to unsigned int. And when used in this mannor:

    INT set1, set2;

    It is translated by the compiler as:

    unsigned int * set1, *set2;

    But I am not accustomed to this usage:

    typedef WCHAR * PWCHAR, * LPWCH, * PWCH, *NEPSTR, *LPWSTR, * PWSTR;

    And I should also specify that WCHAR is also a typedef:

    typedef wchar_t WCHAR:

    Can anyone help me out, especially in describing how the typedef works with a list of types. Is * PWSTR the alias for all of the list?

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    41
    I would say that PWCHAR, LPWCH, PWCH, NEPSTR, LPWSTR and PWSTR are all of type pointer to wchar_t.
    So it shouldn't matter if you type
    PWCHAR test;
    NEPSTR test;
    or
    LPWSTR test;

    But as always, I can't and won't guarantee that. =)

  3. #3
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    You could be right. I haven't tested it yet, but I thought that someone might just know the answer. What you say could be true. I'll know sometime tonight hopefully. Thanks.

  4. #4
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    I would say that PWCHAR, LPWCH, PWCH, NEPSTR, LPWSTR and PWSTR are all of type pointer to wchar_t.
    So it shouldn't matter if you type
    I think one of the reasons why the windows api so ugly is because you have 4 or so different names for a charecter type and then you have the now obselete long pointers and stuft. Since I'm not used to it; I don't usually think of something like
    LPSTR s; as a pointer type. But using typedef is easy. It works the same way as if you were defining a variable but that variable is now a type alias.

    So to define a int and a int*
    int A, *B;
    And create type alias for a int and a int*
    typedef int A, *B;

    typedef WCHAR * PWCHAR, * LPWCH, * PWCH, *NEPSTR, *LPWSTR, * PWSTR;
    To work out this one
    WCHAR *PWCHAR, *LPWCH, *PWCH, *NEPSTR, *LPWSTR, *PWSTR;
    Defines 6 pointers to WCHAR. When you put the typedef you create 6 type alias for a pointer to WCHAR.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Need help understanding info in a header file
    By hicpics in forum C Programming
    Replies: 8
    Last Post: 12-02-2005, 11:36 AM
  3. Please STICKY this- vital to MSVC 6 dev - BASETSD.h
    By VirtualAce in forum Game Programming
    Replies: 11
    Last Post: 03-15-2005, 08:22 AM
  4. build errors migrated from dx9b to dx9c sdk
    By reanimated in forum Game Programming
    Replies: 4
    Last Post: 12-17-2004, 06:35 AM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 11:54 AM

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