PATCH: use standard offsetof()
Marcus Meissner
marcus at jet.franken.de
Tue Sep 7 00:27:32 CDT 2004
Hi,
gcc 3.5 no longer likes our own OFFSETOF() macro in winebuild, so we should
use the standard one from <stddef.h>
Ciao, Marcus
Changelog:
Use offsetof() from stddef.h instead of defining our own OFFSETOF.
Index: tools/winebuild/res32.c
===================================================================
RCS file: /home/wine/wine/tools/winebuild/res32.c,v
retrieving revision 1.15
diff -u -r1.15 res32.c
--- tools/winebuild/res32.c 18 May 2004 21:27:44 -0000 1.15
+++ tools/winebuild/res32.c 7 Sep 2004 05:26:05 -0000
@@ -344,6 +344,8 @@
/* directory structures */
+ fprintf( outfile, "#include <stddef.h>\n" );
+
fprintf( outfile, "struct res_dir {\n" );
fprintf( outfile, " unsigned int Characteristics;\n" );
fprintf( outfile, " unsigned int TimeDateStamp;\n" );
@@ -360,7 +362,6 @@
/* resource directory definition */
- fprintf( outfile, "#define OFFSETOF(field) ((char*)&((struct res_struct *)0)->field - (char*)((struct res_struct *) 0))\n" );
fprintf( outfile, "static struct res_struct{\n" );
fprintf( outfile, " struct res_dir type_dir;\n" );
fprintf( outfile, " struct res_dir_entry type_entries[%d];\n", tree->nb_types );
@@ -405,10 +406,10 @@
for (i = 0, type = tree->types; i < tree->nb_types; i++, type++)
{
if (!type->type->str)
- fprintf( outfile, " { 0x%04x, OFFSETOF(name_%d_dir) | 0x80000000 },\n",
+ fprintf( outfile, " { 0x%04x, offsetof(struct res_struct, name_%d_dir) | 0x80000000 },\n",
type->type->id, i );
else
- fprintf( outfile, " { OFFSETOF(type_%d_name) | 0x80000000, OFFSETOF(name_%d_dir) | 0x80000000 },\n",
+ fprintf( outfile, " { offsetof(struct res_struct, type_%d_name) | 0x80000000, offsetof(struct res_struct, name_%d_dir) | 0x80000000 },\n",
i, i );
}
fprintf( outfile, " },\n" );
@@ -421,10 +422,10 @@
for (n = 0, name = type->names; n < type->nb_names; n++, name++)
{
if (!name->name->str)
- fprintf( outfile, " { 0x%04x, OFFSETOF(lang_%d_%d_dir) | 0x80000000 },\n",
+ fprintf( outfile, " { 0x%04x, offsetof(struct res_struct, lang_%d_%d_dir) | 0x80000000 },\n",
name->name->id, i, n );
else
- fprintf( outfile, " { OFFSETOF(name_%d_%d_name) | 0x80000000, OFFSETOF(lang_%d_%d_dir) | 0x80000000 },\n",
+ fprintf( outfile, " { offsetof(struct res_struct, name_%d_%d_name) | 0x80000000, offsetof(struct res_struct, lang_%d_%d_dir) | 0x80000000 },\n",
i, n, i, n );
}
fprintf( outfile, " },\n" );
@@ -435,7 +436,7 @@
name->nb_languages, i, n );
for (k = 0, res = name->res; k < name->nb_languages; k++, res++)
{
- fprintf( outfile, " { 0x%04x, OFFSETOF(data_entries[%d]) },\n",
+ fprintf( outfile, " { 0x%04x, offsetof(struct res_struct, data_entries[%d]) },\n",
res->lang, res - spec->resources );
}
fprintf( outfile, " },\n" );
@@ -466,6 +467,6 @@
}
}
}
- fprintf( outfile, " }\n};\n#undef OFFSETOF\n\n" );
+ fprintf( outfile, " }\n};\n" );
free_resource_tree( tree );
}
More information about the wine-patches
mailing list