Hello
given the code
are bothCode:struct COORD {float x,y,z};
andCode:sizeof (struct COORD)both valid?Code:sizeof (COORD}
Hello
given the code
are bothCode:struct COORD {float x,y,z};
andCode:sizeof (struct COORD)both valid?Code:sizeof (COORD}
Only the first is valid after fixing the structure declaration. C requires the struct keyword (unlike C++) except when the struct has been typedef'd. If you did this:
Then they would both be valid in C. Note that the structure tag and the typedef identifier are both in different name spaces, and thus the same name can be used. But it can be confusing to some readers.Code:typedef struct COORD {float x,y,z;} COORD;
My best code is written with the delete key.
I never did like the necessity of using 'struct' to declare them, but as prelude says, just use typedef and you'll be fine
Last edited by kinghajj; 05-19-2004 at 08:53 PM. Reason: mis-spelling
01011001 01101111 01110101 00100000 01110100 01101111 01101111 1101011 00100000 01110100 01101000 01101001 01110011 00100000 01101101 01110101 01100011 01101000 00100000 01110100 01101000 01101101 01100101 00100000 01110100 01101111 00100000 01110010 01100101 01100001 01100100 00100000 01011001 01101000 01101001 01110011 00111111 00100000 01000100 01100001 01101101 01101110 00100001 00000000
I assume you meant struct, I always like the struct keyword, kind of made the language unique, unlike the c++ style where structs are like, well, typedef'ed variables
Help populate a c/c++ help irc channel
server: irc://irc.efnet.net
channel: #c
pardon my ignorance but what is a name space?
>pardon my ignorance but what is a name space?
Code:6.2.3 Name spaces of identifiers 1 If more than one declaration of a particular identifier is visible at any point in a translation unit, the syntactic context disambiguates uses that refer to different entities. Thus, there are separate name spaces for various categories of identifiers, as follows: — label names (disambiguated by the syntax of the label declaration and use); — the tags of structures, unions, and enumerations (disambiguated by following any24) of the keywords struct, union, or enum); — the members of structures or unions; each structure or union has a separate name space for its members (disambiguated by the type of the expression used to access the member via the . or -> operator); — all other identifiers, called ordinary identifiers (declared in ordinary declarators or as enumeration constants).
My best code is written with the delete key.