[gmx-developers] Gromacs in C++

David van der Spoel spoel at xray.bmc.uu.se
Tue Sep 21 23:05:23 CEST 2010


On 2010-09-21 22.27, Christian Mötzing wrote:
> 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
>
We will transition the head branch to C++ soon. Right now 4.5.1 and the 
head branch compile in C++ already, but with many warnings. There are no 
plans to do this for 4.0.7.

-- 
David van der Spoel, Ph.D., Professor of Biology
Dept. of Cell & Molec. Biol., Uppsala University.
Box 596, 75124 Uppsala, Sweden. Phone:	+46184714205.
spoel at xray.bmc.uu.se    http://folding.bmc.uu.se



More information about the gromacs.org_gmx-developers mailing list