[ghemical-devel] Ghemical Crash
Jason Rigby
sirjasonr at gmail.com
Tue May 23 03:25:52 EDT 2006
Hey Tommi,
Still getting some errors sadly... here is output from make:
views.cpp: In function 'void* convert_cset_to_plotting_udata(project*,
i32s)':
views.cpp:260: error: pointer of type 'void *' used in arithmetic
views.cpp: In function 'void apply_udata_as_cset(project*, void*)':
views.cpp:281: error: pointer of type 'void *' used in arithmetic
make[2]: *** [views.o] Error 1
make[2]: Leaving directory `/home/jason/Desktop/ghemical-2.01/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/jason/Desktop/ghemical-2.01/src'
make: *** [all-recursive] Error 1
And here is the modified code:
void * convert_cset_to_plotting_udata(project * mdl, i32s cset)
{
void * udata = malloc(sizeof(i32s) + sizeof(fGL) * mdl->GetAtomCount() *
3);
// first, store the number of atoms in the model, as a simple way to
test data validity...
i32s * ptr1 = (i32s *) udata;
(* ptr1) = mdl->GetAtomCount();
// then just store the coordinates...
fGL * ptr2 = (fGL *) ( udata + sizeof(i32s)); i32s counter = 0;
for (iter_al it1 = mdl->GetAtomsBegin();it1 != mdl->GetAtomsEnd();it1++)
{
const fGL * cdata = (* it1).GetCRD(cset);
ptr2[counter++] = cdata[0];
ptr2[counter++] = cdata[1];
ptr2[counter++] = cdata[2];
}
return udata;
}
void apply_udata_as_cset(project * prj, void * udata)
{
i32s * ptr1 = (i32s *) udata;
if (prj->GetAtomCount() != (* ptr1))
{
cout << "oops!!! the atom counts are different." << endl;
return;
}
fGL * ptr2 = (fGL *) ( udata + sizeof(i32s)); i32s counter = 0;
for (iter_al it1 = prj->GetAtomsBegin();it1 != prj->GetAtomsEnd();it1++)
{
const i32s cset = 0; // how to set this?!?!?!
fGL x = ptr2[counter++];
fGL y = ptr2[counter++];
fGL z = ptr2[counter++];
(* it1).SetCRD(cset, x, y, z);
}
prj->UpdateAllGraphicsViews();
// also make sure that if user calculates any results, the new structure
will be used!
//
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
prj->GetCurrentSetup()->DiscardCurrentEngine();
}
Thanks for your help,
Jason
On 23/05/06, Tommi Hassinen <thassine at messi.uku.fi> wrote:
>
> On Wed, 17 May 2006, Jason Rigby wrote:
>
> > Thanks for the reply Tommi,
> > I tried to compile Ghemical 2.01 but, as always, I ran into some
> issues.....
>
> > views.cpp:260: error: cast from 'void*' to 'i32u' loses precision
> > views.cpp: In function 'void apply_udata_as_cset(project*, void*)':
> > views.cpp:281: error: cast from 'void*' to 'i32u' loses precision
> > make[2]: *** [views.o] Error 1
> > make[2]: Leaving directory `/home/jason/Desktop/ghemical-2.01/src'
> > make[1]: *** [all] Error 2
> > make[1]: Leaving directory `/home/jason/Desktop/ghemical-2.01/src'
> > make: *** [all-recursive] Error 1
> >
> > Again, any help would be appreciated!
>
> The line in question is:
>
> fGL * ptr2 = (fGL *) ((i32u) udata + sizeof(i32s)); i32s counter = 0;
>
> Your compiler seems to think that the pointer arithmetics is done badly.
> Try this modification:
>
> fGL * ptr2 = (fGL *) ( udata + sizeof(i32s)); i32s counter = 0;
> ^^^^^^^
> that is, just remove the int-cast that seems to be unnecessary. The same
> for line 281.
>
> I hope this helps,
>
> Tommi
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://bioinformatics.org/pipermail/ghemical-devel/attachments/20060523/aa33febb/attachment.html
More information about the ghemical-devel
mailing list