Just an aside that may or may not be relevant.

In the old days, often variable-length resources and other OS types would have a struct defined for them that used a fixed field size to represent some variable length field in the real resource, for example:

typedef struct
{
    short count;
    long  stuff[1]; // in reality <count> length
}
someResTypeStruct;

This is simply because you can't express variable length structs in C. So using sizeof(someResTypeStruct) == GetHandleSize(anActualResource) very often doesn't work, never has worked, and definitely shouldn't be relied upon. Same goes for allocating memory for such resources, which is why many common types had their own NewXXX function.

That said, you can use C structs in Objective-C normally, just be aware that they might only describe part of the real resource itself (the header, say).



hth,

Graham


On 27 Jun 2008, at 1:00 pm, Tran Kim Bach wrote:

but in reality, in my application, the resource size for this type(PREC) is
various for each resource file(.rsrc).
So, I think the struct caused my problem ( I never thought of it before).
By the way, I have a lot of structs of the same resource type(PREC for
example) written in C,
Is there any way to still take advantage of them in Objective-C?
(I mean if I can use these C structs in Objective-C?, don't have to rewrite
them using Objective-C language).

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to