info-inventor-dev
[Top] [All Lists]

Re: Solaris g++/gcc: crashes in Material Editor and Color Editor..

To: Simon.Ney@xxxxxxxxxxxxxxxxxxxxxxxxxxx
Subject: Re: Solaris g++/gcc: crashes in Material Editor and Color Editor..
From: "J.A. Magallon" <jamagallon@xxxxxxx>
Date: Mon, 9 Sep 2002 16:20:46 +0200
Cc: "Vincent S. Cojot" <coyote@xxxxxxxxxxxxxxx>, info-inventor-dev@xxxxxxxxxxx
In-reply-to: <3D79B350.FEBB6DFD@neural.home.cs.tu-berlin.de>; from Simon.Ney@neural.home.CS.TU-Berlin.DE on Sat, Sep 07, 2002 at 10:05:36 +0200
References: <1721.212.208.45.51.1031315574.squirrel@mail.step.polymtl.ca> <3D78E2CD.79D9A69@neural.home.cs.tu-berlin.de> <20020906221451.GI1931@werewolf.able.es> <3D79B350.FEBB6DFD@neural.home.cs.tu-berlin.de>
Sender: info-inventor-dev-bounce@xxxxxxxxxxx
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))

<Prev in Thread] Current Thread [Next in Thread>