Thread: [Dev-C++] Struct "tags" and things
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Daniel G. <sp...@ho...> - 2003-02-27 12:06:18
|
typedef struct _MyStruct
{
//...Data
} MyStruct, FAR * LPMYSTRUCT
My questions are
1) Why is it _MyStruct at the top? Is that the structure's real name and
MyStruct is the typedef'd name?
2) I know about FAR pointers, but why is a pointer needed here? Why don't I
just put MyStruct* LPMYSTRUCT; in my code?
Following from this, I see
#define GetMyStructProperties(lpdm) ((LPMYSTRUCT)(lpdm))
and the function is called often. What is going on?
_________________________________________________________________
Stay in touch with MSN Messenger http://messenger.msn.co.uk
|
|
From: Per W. <pw...@ia...> - 2003-02-27 12:18:45
|
The first name directly after struct is an old and strange C thingie,
where the structs lives in their own name-space.
You don't need to declare a pointer type for each data type you create.
It's just that for some environments, the FAR #declare are really needed
and contains __far, far, _far or any number of compiler-specific keyword.
By having declared a pointer type containing that extra FAR thingie, you
don't have to remember to use it everywhere in your program whenever you
need a pointer.
For the majority of the code you write, just do what you like.
/Per W
On Thu, 27 Feb 2003, Daniel Glenfield wrote:
>
>
> typedef struct _MyStruct
> {
> //...Data
>
> } MyStruct, FAR * LPMYSTRUCT
>
>
> My questions are
> 1) Why is it _MyStruct at the top? Is that the structure's real name and
> MyStruct is the typedef'd name?
>
> 2) I know about FAR pointers, but why is a pointer needed here? Why don't I
> just put MyStruct* LPMYSTRUCT; in my code?
>
>
> Following from this, I see
> #define GetMyStructProperties(lpdm) ((LPMYSTRUCT)(lpdm))
>
>
> and the function is called often. What is going on?
>
>
> _________________________________________________________________
> Stay in touch with MSN Messenger http://messenger.msn.co.uk
>
>
>
> -------------------------------------------------------
> This SF.NET email is sponsored by:
> SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
> http://www.vasoftware.com
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Ioannis V. <no...@ho...> - 2003-02-27 13:56:39
|
-------Original Message-------=0D
=0D
From: Daniel Glenfield=0D
Date: =D0=DD=EC=F0=F4=E7, 27 =D6=E5=E2=F1=EF=F5=DC=F1=E9=EF=F2 2003 2:08:=
53 =EC=EC=0D
To: dev...@li...=0D
Subject: [Dev-C++] Struct "tags" and things=0D
=0D
=0D
typedef struct _MyStruct=0D
{=0D
//...Data=0D
=0D
} MyStruct, FAR * LPMYSTRUCT=0D
=0D
=0D
My questions are=0D
1) Why is it _MyStruct at the top? Is that the structure's real name and =
=0D
MyStruct is the typedef'd name?=0D
=0D
=0D
=3D=3D> _MyStruct is the name of the type and MyStruct is a synonym. It i=
s
equivalent of:=0D
=0D
struct _MyStruct=0D
{=0D
// ...=0D
}FAR * LPMYSTRUCT;=0D
=0D
typedef _MyStruct MyStruct;=0D
=0D
=0D
=0D
=0D
=0D
2) I know about FAR pointers, but why is a pointer needed here? Why don't=
I =0D
just put MyStruct* LPMYSTRUCT; in my code?=0D
=0D
=0D
=3D=3D> FAR is a system dependent keyword. The above is equivalent to:=0D
=0D
MyStruct FAR *LPMYSTRUCT;=0D
=0D
=0D
=0D
=0D
Ioannis Vranos=0D
=0D
* Programming pages: http://www.noicys.freeurl.com=0D
* Alternative URL: http://run.to/noicys=20 |
|
From: Ioannis V. <no...@ho...> - 2003-02-27 13:59:27
|
A correction:=0D
=0D
=0D
=0D
-------Original Message-------=0D
=0D
From: Ioannis Vranos=0D
Date: =D0=DD=EC=F0=F4=E7, 27 =D6=E5=E2=F1=EF=F5=DC=F1=E9=EF=F2 2003 3:56:=
22 =EC=EC=0D
To: dev...@li...=0D
Subject: Re: [Dev-C++] Struct "tags" and things=0D
=0D
-------Original Message-------=0D
=0D
From: Daniel Glenfield=0D
Date: =D0=DD=EC=F0=F4=E7, 27 =D6=E5=E2=F1=EF=F5=DC=F1=E9=EF=F2 2003 2:08:=
53 =EC=EC=0D
To: dev...@li...=0D
Subject: [Dev-C++] Struct "tags" and things=0D
=0D
=0D
typedef struct _MyStruct=0D
{=0D
//...Data=0D
=0D
} MyStruct, FAR * LPMYSTRUCT=0D
=0D
=0D
My questions are=0D
1) Why is it _MyStruct at the top? Is that the structure's real name and =
=0D
MyStruct is the typedef'd name?=0D
=0D
=0D
=3D=3D> _MyStruct is the name of the type and MyStruct is a synonym. It i=
s
equivalent of:=0D
=0D
struct _MyStruct=0D
{=0D
// ...=0D
}FAR * LPMYSTRUCT;=0D
=0D
typedef _MyStruct MyStruct;=0D
=0D
=0D
=0D
=0D
=0D
2) I know about FAR pointers, but why is a pointer needed here? Why don't=
I =0D
just put MyStruct* LPMYSTRUCT; in my code?=0D
=0D
=0D
=3D=3D> FAR is a system dependent keyword. The above is equivalent to:=0D
=0D
Corrected: typedef _MyStruct FAR *LPMYSTRUCT;=0D
=0D
=0D
=0D
=0D
Ioannis Vranos=0D
=0D
* Programming pages: http://www.noicys.freeurl.com=0D
* Alternative URL: http://run.to/noicys=20 |
|
From: Ioannis V. <no...@ho...> - 2003-02-27 14:02:37
|
Duh. Sorry but the previous was not corrected completely (it must be my
lunch). =0D
=0D
=0D
-------Original Message-------=0D
=0D
From: Ioannis Vranos=0D
Date: =D0=DD=EC=F0=F4=E7, 27 =D6=E5=E2=F1=EF=F5=DC=F1=E9=EF=F2 2003 3:59:=
15 =EC=EC=0D
To: Dev-C++ Mailing List=0D
Subject: Re: [Dev-C++] Struct "tags" and things=0D
=0D
A correction:=0D
=0D
=0D
=0D
-------Original Message-------=0D
=0D
From: Ioannis Vranos=0D
Date: =D0=DD=EC=F0=F4=E7, 27 =D6=E5=E2=F1=EF=F5=DC=F1=E9=EF=F2 2003 3:56:=
22 =EC=EC=0D
To: dev...@li...=0D
Subject: Re: [Dev-C++] Struct "tags" and things=0D
=0D
-------Original Message-------=0D
=0D
From: Daniel Glenfield=0D
Date: =D0=DD=EC=F0=F4=E7, 27 =D6=E5=E2=F1=EF=F5=DC=F1=E9=EF=F2 2003 2:08:=
53 =EC=EC=0D
To: dev...@li...=0D
Subject: [Dev-C++] Struct "tags" and things=0D
=0D
=0D
typedef struct _MyStruct=0D
{=0D
//...Data=0D
=0D
} MyStruct, FAR * LPMYSTRUCT=0D
=0D
=0D
My questions are=0D
1) Why is it _MyStruct at the top? Is that the structure's real name and =
=0D
MyStruct is the typedef'd name?=0D
=0D
=0D
=3D=3D> _MyStruct is the name of the type and MyStruct is a synonym. It i=
s
equivalent of:=0D
=0D
struct _MyStruct=0D
{=0D
// ...=0D
};=0D
=0D
typedef _MyStruct MyStruct;=0D
typedef _MyStruct FAR * LPMYSTRUCT;=0D
=0D
=0D
=0D
=0D
=0D
2) I know about FAR pointers, but why is a pointer needed here? Why don't=
I =0D
just put MyStruct* LPMYSTRUCT; in my code?=0D
=0D
=0D
=3D=3D> FAR is a system dependent keyword. The above is equivalent to:=0D
=0D
typedef _MyStruct FAR *LPMYSTRUCT;=0D
=0D
=0D
=0D
=0D
Ioannis Vranos=0D
=0D
* Programming pages: http://www.noicys.freeurl.com=0D
* Alternative URL: http://run.to/noicys=20 |