typedef arrangement CL doesn't like

typedef
{ unsigned __int8 uint8;
  unsigned __int16 uint16;
  unsigned __int32 uint32;
  unsigned __int8 char8;
  char8 * string8;
  signed __int32 BOOL;
  __int32 WPARAM;
  __int32 LPARAM;
  __int32 HWND;
  unsigned __int32 UINT;
  __stdcall CALLBACK;
}

Can someone please tell me why this is wrong More specifically, the compiler seems to want a typedef statement for each typedef, and I haven't seen the rule that makes this an unacceptable shortcut.


Answer this question

typedef arrangement CL doesn't like

  • duncan_goldcoast

    Well, all I can say is if you have issues with the syntax of C/C++ take it up with the ANSI bord, since the compiler is aiming to be ANSI complient and that includes all the weirdnesses that the standard include.

  • Enzima

    By compiler, I am referring to the program CL.exe. In English programs are 'it's not 'he's.
    __stdcall is more like a type than struct is, going where you would also put a type for functions.

  • Joachim Juell

    I don't know what you are talking about. struct is a keyword. function is nothing.

    typedef does not define keywords. It defines types. I stop now. This discussion targets nothing and helps nobody.



  • chuckles

    There is nothing in the definition of typedef that allows a keyword to be in the typedef statement, just like there is nothing in the definition of typedef that allows brackets. There is no reason why typedef should balk at brackets but allow struct, or balk at struct but allow brackets.

    Also you are completely wrong when you say typedef defines types. typedef defines new names for pre-existing types.

    Did you even read entirely http://msdn.microsoft.com/library/default.asp url=/library/en-us/vccelng/htm/tions_14.asp

    or did you just look at
    typedef type-declaration synonym;

    and then stop

  • Fotis Elianos

    I have issues with the documentation of the C syntax. It reeks. Because of this, the learning curve for C is much higher than it needs to be.

  • bt8114

    You are wrong. The brackets are belonging to the definition of the struct and does no mention the typedef syntax.

    typedef void DRAWF(int,int); Absolutly follow the rules! Because here a function is defined and () tights close.



  • steveQ56

    because "struct" is not a type declaration and once that is included, brackets are allowed.

    typedef void DRAWF( int, int ); doesn't follow the rules as explained either.

    Again:
    typedef char CHAR, *PSTR;


    Plus all the other places where brackets are allowed, suggests it would not be unlikely here. Plus, I know of no good reason why the programming language wasn't designed to alow brackets  to be used like this. It would be the eqivalent of saying all these items fall within the scope of a typedef argument.

  • Mediocretes

    "function" is not a defined type, neither is "struct"

  • Riju

    The microsoft document page on typedef is lousy.

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/vccelng/htm/tions_14.asp

    The confusion was not over how many arguements struct is to typedef, but why it can be an argument to typedef at all, since it isn't a type.

    Whenever brackets are used they are in place of a set of tokens followed by a simicolon, so why shoudn't one be able to replace any string of tokens followed by a simicolon with a set of brackets..

  • B. Ritter

    I don't know where you got your typdef knowladge from, but most of what you say is wrong.

    typedef sturct thisstruct{...} whatever;

    This works because the compiler creates a synonym for the struct, so when you type out whatever the compiler translates it to struct thisstruct. It can be though of as being similar to #define struct thisstruct whatever

    typedef struct{...} whatever;

    This works because the compiler defines a unique anonymous value for the structure, it is that simple. It then follows the same procedure as stated above.

    The struct is also only counted as one argument of the typdef so it still follows the syntax of one definition per typdef.

    __stdcall isn't a type, in fact when the program is compiled it is lost completely. If you don't believe me on this, create an asm output file and look at the functions and the way that the functions are called. __stdcall, like __fastcall and __cdecl are the way that the functions are called, this is important because the calling conventions don't mix. So why doesn't __stdcall count as a type, because it is how the function is called, not really part of the function decleration itself. Since the typdef is there to create a fast way of defining a function then it wouldn't include the calling convention. Since one of the biggest issues is what happens if you require different calling conventions for the same function signiture. So the calling convention should be applied to the definition itself.

    Also why did you bring natural languages and go off saying this is about CL, it is always about CL since that is the c/c++ compiler front end.



  • Teetime

    Whats wrong This is the wrong syntax!

    The correct syntax is
    typedef type-declaration synonym;

    And there is no other defintion for it:
    http://msdn.microsoft.com/library/default.asp url=/library/en-us/vccelng/htm/tions_14.asp

    Why do you expect this to be correct

    As you wrote: every typedef must be a typedef for its own.
    typedef unsigned __int8 uint8;
    typedef unsigned __int16 uint16;
    typedef unsigned __int32 uint32;




  • TheSteve

    also the compiler doesn't like typedef __stdcall CALLBACK;

  • icon_snowman

    I brought in natural languages because Martin Richter is German, and in German words have gender, so when I said "compiler", he used the gender pronoun "he".

    All types are lost when a program is compiled.

    I started out programming in QuickBASIC with coding support routines in Assembly and spent quite a bit of time doing that, so much of my perspective is colored by it.

    Freebasic of Freebasic.net is a modern BASIC built on the QB syntax. I bring this up because there is quite a few people slamming QB.


  • intech

    How should he. Again __stdacall is no type its an attribute defining how a type of a function should handle the arguments.

    typedef is nothing like define!

  • typedef arrangement CL doesn't like