lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Is it me, or does the below typedef not parse with tolua 3.0b?  (It chokes on
> the filename[64] field.)
> 
> typedef struct {
>         short vRefNum;
>         short refNum;
>         unsigned char filename[64];
>         unsigned char path[256];
> }file_info;
> 

in the .pkg file,
you should use "unsigned char* filename" instead,
and tolua should run just fine.

note, however, that you cannot assign string values from Lua
in such a case. Assuming "fi" is a lua variable holding an object
of that kind, the code:

print(fi.filename)

would work fine, but

fi.filename = "file"

would be wrong. It would be equivalent to the C statment:

fi->filename = "file";

what is not correct, right?

to prevent this error in using the binding code,
you can set those fields as read-only:

typedef struct {
         short vRefNum;
         short refNum;
         const unsigned char* filename;
         const unsigned char* path;
}file_info;


hope this helps.

-- waldemar