That doesn't seem to do the trick:
View attachment 84168
Sorry, I keep forgetting that people don't
typedef every
struct. Try
(struct browser *) , it ought to work.
My general opinion is that pascal's approach is better. It rarely makes sense to define a struct declaration if you're going to use it more than once.
For example,
C:
struct sMyXY {
int iX,iY;
};
struct {
uint8_t iLen;
char iText[100]; // up to 100 chars..
} gMyStr100;
Both of these forms are almost always frustrating. You can't refer to
sMyXY by itself, instead you always have to refer to
struct sMyXY so it involves extra typing and at some point a programmer will forget to prefix
sMyXY with a
struct. In the case of
gMyStr100, you're stuck with that single variable of that kind: you can't pass it as a parameter for use in other functions, it's a standalone declaration that can't be reused. Super annoying IMHO. It should be:
C:
typedef struct {
int iX,iY;
}tMyXY; // the type, you just need this.
typedef struct {
uint8_t iLen;
char iText[100]; // up to 100 chars..
}tMyStr100; // now we can re-use tMyStr100 for more vars or params.
tMyStr100 gMyStr100;
There's one case where it does make sense though, where you need to refer to the structure from within the struct (e.g. a list definition).
C:
typedef struct {
int iX, iY;
tMyList *iNext; // point to next in list. *Doesn't Work!*.
}tMyList;
typedef struct sMyList {
int iX, iY;
struct sMyList *iNext; // You need to use this form, tMyList doesn't exist yet.
}tMyList; // only now tMyList exists.
So, in 'C' the name of the type isn't known in a
typedef until the end. It's a dumb syntax decision which derived from the pre-1978 era of 'C' where you could define a
struct, but you
couldn't define a type (
typedef didn't exist, programmers used
#define instead). So, they made struct definitions first take the same syntax as a variable definition, e.g.
int x; becomes
struct { int a,b,c,d; } x; and then since you usually wanted to re-use it, they bodged on a name for the
struct after '
struct'...
struct FourInts { int a,b,c,d; } x; [which is a struct template + a variable based on the template].
C++ fixes that. simply typing
struct tFourInts { int a,b,c,d; }; defines it as a type rather than a template. Anyway, 'C' rant over ;-) !