Help with typedef struct

Hey,
I am working on converting C++ code from Visual Studio 6.0 to Visual Studio 2010. I have came upon the following code and don't fully understand:
1
2
3
4
5
6
typedef struct st_l16 s_l16;

typedef struct st_l16
{
 declared varables are here
}; 


In another file the following code exists:
 
num = s_l16->host_nav_data.platform_lat;//Once in VS 2010 I get an error for this stating thast s_l16 is undeclared, but no error in VS 6.0 


Any help will be greatly appreciated!!
Thanks In Advance!!
Beats me. according to the typedef, s_116 is a type and therefore cannot be applied operator->. Unless VS 2010 wants you to declare the struct first? Try that.

BTW, the struct declaration is incomplete. It lacks a name at the end. Personally I would merge the 2 like this:

1
2
3
4
typedef struct st_116
{
    ....
} s_116;
Last edited on
In C++ you don't need to typedef your struct. This is sufficient:
1
2
3
4
struct st_l16
{
    //declared varables are here
}; 

Using typedef struct is a hangover from C where it was necessary if you wanted to avoid typing keyword struct all the time.

You code doesn't make much sense to me. s_l16 is declared as a type and then later used as a variable...?
closed account (zb0S216C)
I use type-defined structs most of the time. It's best to read upon typedef to understand what's truly happening. In C++, type-defined structs don't affect the code, so type-defining structs is theoretically a personal preference.

References:
[1]http://publib.boulder.ibm.com/infocenter/lnxpcomp/v7v91/index.jsp?topic=%2Fcom.ibm.vacpp7l.doc%2Flanguage%2Fref%2Fclrc03typdef.htm


Wazzak
Topic archived. No new replies allowed.