On 2002.09.07 Simon Ney wrote:
>Hi,
>
># find . -type f | xargs grep -l SV_OFFSET
>./apps/demos/SceneViewer/SoSceneMenu.h
>
># find . -type f | xargs grep -l SoSceneMenu.h
>./apps/demos/SceneViewer/SoSceneViewer.c++
>
>
>SV_OFFSET is used to construct "XtResource intl_light_resources[]" data
>structures in SoSceneMenu.h
>this data is used by the "X-Window system" when the widget (i think is
>was a form-widget) is created.
>
>it is not possible to calculate offsets between different "memory
>sections"
[...]
> { "ambientLighting", NULL, XtRString, sizeof(XtRString),
> (Cardinal) SV_OFFSET(&lightData[4].name, &lightData[0]),
OK ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> XtRString, (XtPointer) "Ambient Lighting...",},
> { "headlight", NULL, XtRString, sizeof(XtRString),
> (Cardinal) SV_OFFSET(&Light.headlight, &lightData[0]),
???? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> XtRString, (XtPointer) "Headlight ",},
What I do not understand is who the he** wrote this. Taking an offset
betwwen two different global variables (ie, not in stack or in the same
struct) is at best non portable (dependent on compiler-linker behaviour)
and probably _wrong_.
If both 'light_data' and 'Light' are preference data for the app, put
both into a struct:
struct LightData
{
char *headlight;
...
}
static struct {
static SoSceneViewerButton lightData[];
LightData Light;
} prefs =
{
{ {"Create Dir Light",SV_LIGHT_ADD_DIRECT,SV_PUSH_BUTTON,0,0},
...
},
{ "XXXhead","XXXedit","XXXdirectional","XXXspot", "XXXpoint" }
};
--
J.A. Magallon <jamagallon@xxxxxxx> \ Software is like sex:
werewolf.able.es \ It's better when it's free
Mandrake Linux release 9.0 (Cooker) for i586
Linux 2.4.20-pre5-jam1 (gcc 3.2 (Mandrake Linux 9.0 3.2-1mdk))
|