Re: void* passed as funtion parameters?
- From: "Igor Tandetnik" <itandetnik@xxxxxxxx>
- Date: Tue, 1 Sep 2009 08:10:07 -0400
Ulrich Eckhardt wrote:
Some suggestions:
1. You could use a union type to store the array and store the array
in the initial members of the struct, so that you can factor out a
base-struct that contains the pointer/size_t combo.
2. You could also attach the type to the struct itself, like in the
first member an enumeration. This would allow you to distinguish the
type easier. You could then treat the void pointer as pointer to the
enumeration, read it, and then treat the different types accordingly.
3. You could also attach a function-pointer for various things that
have common behaviour but actually different implementations for
different types.
4. Since the only thing these structs have in common is an accident of
having members with the same name, you could use a macro in place of a
function:
#define f(p) \
do { \
(p)->LK__F1 = 10; \
(p)->dc[0].LKdct__F1 = 20; \
} while (0)
But give your macro some long and ugly name other than "f".
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
.
- Follow-Ups:
- Re: void* passed as funtion parameters?
- From: Robby
- Re: void* passed as funtion parameters?
- References:
- Re: void* passed as funtion parameters?
- From: Robby
- Re: void* passed as funtion parameters?
- From: Ulrich Eckhardt
- Re: void* passed as funtion parameters?
- Prev by Date: Re: Unusual usage of IUknown
- Next by Date: Process Name
- Previous by thread: Re: void* passed as funtion parameters?
- Next by thread: Re: void* passed as funtion parameters?
- Index(es):
Relevant Pages
|