[gmx-developers] Gromacs in C++

Christian Mötzing christian at moetzing.net
Tue Sep 21 22:27:50 CEST 2010


Hi,

I tried to compile Gromacs in with g++ today and I had no success.

I tried to find something in the archive, but the serach does not seem
to work correctly. If I search for C++ nothing turns up. If I search for
smalloc.h one of the first hits is "compiling with c++". Why can't this
be found via searching for C++?

Now to the real problem. I used the tarball of 4.0.7. At first I got
some const char* error which are easy to fix. Next one is this:

nonbonded.c: In function ‘void gmx_setup_kernels(FILE*)’:
nonbonded.c:194: error: invalid conversion from ‘void*’ to ‘void
(**)(int*, int*, int*, int*, int*, real*, real*, int*, real*, real*,
real*, real*, real*, real*, real*, int*, int*, real*, real*, real*,
real*, real*, real*, real*, real*, int*, int*, void*, int*, int*,
real*)’
nonbonded.c: At global scope:
nonbonded.c:808: error: expected ‘}’ at end of input
make[5]: *** [nonbonded.lo] Fehler 1

As I understand the reason can be found in smalloc.h:

#define snew(ptr,nelem) (ptr)=save_calloc(#ptr,__FILE__,__LINE__,\
(nelem),sizeof(*(ptr)))

calloc returns void* and assigns it to ptr, no matter what type ptr is.
I think this can't be done without an explicit typecast.

Does Gromacs even support compiling it with g++? I at least found some
#ifdef CPLUSPLUS to ensure C++ compatibility?

All I did was to set CC to g++. Is this correct?

Greetings

Christian




More information about the gromacs.org_gmx-developers mailing list