More files to C++.
authorTeemu Murtola <teemu.murtola@gmail.com>
Wed, 3 Jul 2013 11:00:39 +0000 (14:00 +0300)
committerTeemu Murtola <teemu.murtola@gmail.com>
Sun, 21 Jul 2013 04:29:38 +0000 (07:29 +0300)
Switch a few more files to C++ compilation and resolve issues found: add
several extern "C" declarations, remove unused variables, move some
static variables from headers to source files.  Move gmx_ctime_r()
declaration to string2.h; it must be better to have one extra
declaration in an installed header than a mass of repeated declarations
in source files.  Remove a hack in smalloc.h; the code that prompted
that seems to have been removed in the kernel reorganization for 4.6,
and we are anyways not yet compiling a lot of legacy code with C++.
Suppress most scanf() warnings in these files.  Make cppcheck correctly
parse #ifdef __cplusplus blocks.  Add gmx_isnan().

The motivation for this selection of files is that these files write
output files where either command_line() or Program() is used to
indicate the currently running program.  Will replace those calls with a
uniform mechanism in a subsequent commit.

Change-Id: Ic1e90fcc08b1be6d4d6d257215f9523625ab347a

26 files changed:
src/gromacs/gmxana/binsearch.h
src/gromacs/gmxana/dens_filter.h
src/gromacs/gmxana/gmx_covar.c
src/gromacs/gmxana/gmx_densorder.cpp [moved from src/gromacs/gmxana/gmx_densorder.c with 97% similarity]
src/gromacs/gmxana/gmx_dipoles.cpp [moved from src/gromacs/gmxana/gmx_dipoles.c with 97% similarity]
src/gromacs/gmxana/powerspect.h
src/gromacs/gmxlib/checkpoint.c
src/gromacs/gmxlib/main.cpp [moved from src/gromacs/gmxlib/main.c with 97% similarity]
src/gromacs/gmxlib/maths.c
src/gromacs/gmxlib/matio.cpp [moved from src/gromacs/gmxlib/matio.c with 98% similarity]
src/gromacs/gmxlib/xvgr.cpp [moved from src/gromacs/gmxlib/xvgr.c with 98% similarity]
src/gromacs/gmxpreprocess/CMakeLists.txt
src/gromacs/gmxpreprocess/add_par.h
src/gromacs/gmxpreprocess/gen_vsite.h
src/gromacs/gmxpreprocess/pdb2top.cpp [moved from src/gromacs/gmxpreprocess/pdb2top.c with 97% similarity]
src/gromacs/gmxpreprocess/pgutil.h
src/gromacs/gmxpreprocess/readir.c
src/gromacs/gmxpreprocess/readir.h
src/gromacs/gmxpreprocess/topdirs.h
src/gromacs/legacyheaders/maths.h
src/gromacs/legacyheaders/pdb2top.h
src/gromacs/legacyheaders/smalloc.h
src/gromacs/legacyheaders/string2.h
src/gromacs/legacyheaders/typedefs.h
src/gromacs/mdlib/sim_util.c
tests/CppCheck.cmake

index 0bd47832bb3be03fe8a8d4e704a7c225b468015d..adc04d374bb911984585a3ed2dbe5a150b114069 100644 (file)
 
 #include "types/simple.h"
 
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
 extern void rangeArray(int *ar, int size);
 
 extern void insertionSort(real *ar, int *perm, int start, int end, int direction);
@@ -51,4 +56,8 @@ extern int start_binsearch(real *array, int *perm, int low, int high,
 extern int LinearSearch(double *array, int startindx, int stopindx,
                         double key, int *count, int direction);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
index 2c8069866d017ebfd9cfd64a586ec8f6066781b6..3fbed9a0b83db06474a708f4ffdec213bfcc6a87 100644 (file)
 
 #include "types/simple.h"
 
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
 extern gmx_bool convolution(int dataSize, real* in, int kernelSize,
                             real* kernel);
 extern gmx_bool periodic_convolution(int dsize, real *in, int ksize,
                                      real* kernel);
 extern void gausskernel(real *out, int size, real var);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
index 956fc2fb397fb7a425baf9394396813034482e7e..46b8d4bda9ae863a1e22fb9f13bee0fead33c45a 100644 (file)
 
 #include "gromacs/linearalgebra/eigensolver.h"
 
-/* Portable version of ctime_r implemented in src/gmxlib/string2.c, but we do not want it declared in public installed headers */
-char *
-gmx_ctime_r(const time_t *clock, char *buf, int n);
-
-
 int gmx_covar(int argc, char *argv[])
 {
     const char     *desc[] = {
similarity index 97%
rename from src/gromacs/gmxana/gmx_densorder.c
rename to src/gromacs/gmxana/gmx_densorder.cpp
index a7d7286598a7d9bb8a038a0f60483a561dd99bdb..841b464c20716d3f5a0c18c67390c1054fafe833 100644 (file)
@@ -118,7 +118,7 @@ static void density_in_time (const char *fn, atom_id **index, int gnx[], real bw
     gmx_rmpbc_t  gpbc = NULL;
     matrix       box;                    /* Box - 3x3 -each step*/
     rvec        *x0;                     /* List of Coord without PBC*/
-    int          natoms, i, j, k, n,     /* loop indices, checks etc*/
+    int          i, j,                   /* loop indices, checks etc*/
                  ax1     = 0, ax2 = 0,   /* tangent directions */
                  framenr = 0,            /* frame number in trajectory*/
                  slicex, slicey, slicez; /*slice # of x y z position */
@@ -144,7 +144,7 @@ static void density_in_time (const char *fn, atom_id **index, int gnx[], real bw
             gmx_fatal(FARGS, "Invalid axes. Terminating\n");
     }
 
-    if ( (natoms = read_first_x(oenv, &status, fn, &t, &x0, box)) == 0)
+    if (read_first_x(oenv, &status, fn, &t, &x0, box) == 0)
     {
         gmx_fatal(FARGS, "Could not read coordinates from file"); /* Open trajectory for read*/
 
@@ -182,7 +182,9 @@ static void density_in_time (const char *fn, atom_id **index, int gnx[], real bw
         bbww[ZZ] = box[axis][axis]/ *zslices;
         gmx_rmpbc(gpbc, top->atoms.nr, box, x0);
         /*Reset Densslice every nsttblock steps*/
-        if   (framenr % nsttblock == 0)
+        /* The first conditional is for clang to understand that this branch is
+         * always taken the first time. */
+        if (Densslice == NULL || framenr % nsttblock == 0)
         {
             snew(Densslice, *xslices);
             for (i = 0; i < *xslices; i++)
@@ -194,12 +196,13 @@ static void density_in_time (const char *fn, atom_id **index, int gnx[], real bw
                 }
             }
 
-            /*Allocate Memory to  extra frame in Densdevel -  rather stupid approach:                                          *A single frame each time, although only every nsttblock steps.*/
+            /* Allocate Memory to  extra frame in Densdevel -  rather stupid approach:
+             * A single frame each time, although only every nsttblock steps.
+             */
             srenew(*Densdevel, *tblock+1);
-
+            (*Densdevel)[*tblock] = Densslice;
         }
 
-
         dscale = (*xslices)*(*yslices)*(*zslices)*AMU/ (box[ax1][ax1]*box[ax2][ax2]*box[axis][axis]*nsttblock*(NANO*NANO*NANO));
 
         if (bCenter)
@@ -244,8 +247,6 @@ static void density_in_time (const char *fn, atom_id **index, int gnx[], real bw
             slicey = ((int) (y/bbww[YY])) % *yslices;
             slicez = ((int) (z/bbww[ZZ])) % *zslices;
             Densslice[slicex][slicey][slicez] += (top->atoms.atom[index[0][j]].m*dscale);
-
-
         }
 
         framenr++;
@@ -254,7 +255,6 @@ static void density_in_time (const char *fn, atom_id **index, int gnx[], real bw
         {
             /*Implicit incrementation of Densdevel via renewal of Densslice*/
             /*only every nsttblock steps*/
-            (*Densdevel)[*tblock] = Densslice;
             (*tblock)++;
         }
 
@@ -322,9 +322,8 @@ static void outputfield(const char *fldfn, real ****Densmap,
 static void filterdensmap(real ****Densmap, int xslices, int yslices, int zslices, int tblocks, int ftsize)
 {
     real *kernel;
-    real *output;
     real  std, var;
-    int   i, j, k, n, order;
+    int   i, j, n, order;
     order = ftsize/2;
     std   = ((real)order/2.0);
     var   = std*std;
@@ -355,8 +354,8 @@ static void interfaces_txy (real ****Densmap, int xslices, int yslices, int zsli
     real       *zDensavg; /* zDensavg[z]*/
     int         i, j, k, n;
     int         xysize;
-    int         ndx1, ndx2, deltandx, *zperm;
-    real        densmid, densl, densr, alpha, pos, spread;
+    int         ndx1, ndx2, *zperm;
+    real        densmid;
     real        splitpoint, startpoint, endpoint;
     real       *sigma1, *sigma2;
     real        beginfit1[4];
@@ -657,7 +656,7 @@ int gmx_densorder(int argc, char *argv[])
 
     output_env_t       oenv;
     t_topology        *top;
-    char               title[STRLEN], **grpname;
+    char             **grpname;
     int                ePBC, *ngx;
     static real        binw      = 0.2;
     static real        binwz     = 0.05;
@@ -666,7 +665,7 @@ int gmx_densorder(int argc, char *argv[])
     static int         ftorder   = 0;
     static int         nsttblock = 100;
     static int         axis      = 2;
-    static char       *axtitle   = "Z";
+    static const char *axtitle   = "Z";
     atom_id          **index; /* Index list for single group*/
     int                xslices, yslices, zslices, tblock;
     static gmx_bool    bGraph   = FALSE;
similarity index 97%
rename from src/gromacs/gmxana/gmx_dipoles.c
rename to src/gromacs/gmxana/gmx_dipoles.cpp
index ce92da2b90ec015966b794a72ef2b3f45b3d6fb4..1f0c2edf0693afdad603d9b71670da198e9490a8 100644 (file)
@@ -38,6 +38,8 @@
 #include <string.h>
 #include <math.h>
 
+#include <algorithm>
+
 #include "macros.h"
 #include "statutil.h"
 #include "sysstuff.h"
@@ -85,30 +87,28 @@ static t_gkrbin *mk_gkrbin(real radius, real rcmax, gmx_bool bPhi, int ndegrees)
 
     if ((ptr = getenv("GKRWIDTH")) != NULL)
     {
-        double bw;
-
-        sscanf(ptr, "%lf", &bw);
+        double bw = strtod(ptr, NULL);
         gb->spacing = bw;
     }
     else
     {
         gb->spacing = 0.01; /* nm */
     }
-    gb->nelem   = 1 + radius/gb->spacing;
+    gb->nelem   = 1 + static_cast<int>(radius/gb->spacing);
     if (rcmax == 0)
     {
         gb->nx = gb->nelem;
     }
     else
     {
-        gb->nx = 1 + rcmax/gb->spacing;
+        gb->nx = 1 + static_cast<int>(rcmax/gb->spacing);
     }
     gb->radius  = radius;
     snew(gb->elem, gb->nelem);
     snew(gb->count, gb->nelem);
 
     snew(gb->cmap, gb->nx);
-    gb->ny = max(2, ndegrees);
+    gb->ny = std::max(2, ndegrees);
     for (i = 0; (i < gb->nx); i++)
     {
         snew(gb->cmap[i], gb->ny);
@@ -141,13 +141,13 @@ static void add2gkr(t_gkrbin *gb, real r, real cosa, real phi)
         alpha = acos(cosa);
         if (gb->bPhi)
         {
-            cy = (M_PI+phi)*gb->ny/(2*M_PI);
+            cy = static_cast<int>((M_PI+phi)*gb->ny/(2*M_PI));
         }
         else
         {
-            cy = (alpha*gb->ny)/M_PI; /*((1+cosa)*0.5*(gb->ny));*/
+            cy = static_cast<int>((alpha*gb->ny)/M_PI); /*((1+cosa)*0.5*(gb->ny));*/
         }
-        cy = min(gb->ny-1, max(0, cy));
+        cy = std::min(gb->ny-1, std::max(0, cy));
         if (debug)
         {
             fprintf(debug, "CY: %10f  %5d\n", alpha, cy);
@@ -171,8 +171,8 @@ void do_gkr(t_gkrbin *gb, int ncos, int *ngrp, int *molindex[],
             int ePBC, matrix box, t_atom *atom, int *nAtom)
 {
     static rvec *xcm[2] = { NULL, NULL};
-    int          gi, gj, j0, j1, i, j, k, n, index, grp0, grp1;
-    real         qtot, q, r2, cosa, rr, phi;
+    int          gi, gj, j0, j1, i, j, k, n, grp0, grp1;
+    real         qtot, q, cosa, rr, phi;
     rvec         dx;
     t_pbc        pbc;
 
@@ -247,7 +247,7 @@ void do_gkr(t_gkrbin *gb, int ncos, int *ngrp, int *molindex[],
                     cosa = cos_angle(mu[gi], mu[gj]);
                     phi  = 0;
                 }
-                if (debug || (cosa != cosa))
+                if (debug || gmx_isnan(cosa))
                 {
                     fprintf(debug ? debug : stderr,
                             "mu[%d] = %5.2f %5.2f %5.2f |mi| = %5.2f, mu[%d] = %5.2f %5.2f %5.2f |mj| = %5.2f rr = %5.2f cosa = %5.2f\n",
@@ -265,7 +265,8 @@ void do_gkr(t_gkrbin *gb, int ncos, int *ngrp, int *molindex[],
 static real normalize_cmap(t_gkrbin *gb)
 {
     int    i, j;
-    double hi, vol;
+    real   hi;
+    double vol;
 
     hi = 0;
     for (i = 0; (i < gb->nx); i++)
@@ -274,7 +275,7 @@ static real normalize_cmap(t_gkrbin *gb)
         for (j = 0; (j < gb->ny); j++)
         {
             gb->cmap[i][j] /= vol;
-            hi              = max(hi, gb->cmap[i][j]);
+            hi              = std::max(hi, gb->cmap[i][j]);
         }
     }
     if (hi <= 0)
@@ -336,7 +337,7 @@ static void print_gkrbin(const char *fn, t_gkrbin *gb,
      */
     FILE       *fp;
     const char *leg[] = { "G\\sk\\N(r)", "< cos >", "h\\sOO\\N", "g\\sOO\\N", "Energy" };
-    int         i, j, n, last;
+    int         i, last;
     real        x0, x1, ggg, Gkr, vol_s, rho, gOO, hOO, cosav, ener;
     double      fac;
 
@@ -492,7 +493,6 @@ static void mol_quad(int k0, int k1, rvec x[], t_atom atom[], rvec quad)
     real     q, r2, mass, masstot;
     rvec     com;        /* center of mass */
     rvec     r;          /* distance of atoms to center of mass */
-    real     rcom_m, rcom_n;
     double **inten;
     double   dd[DIM], **ev, tmp;
 
@@ -688,7 +688,7 @@ static void dump_slab_dipoles(const char *fn, int idim, int nslice,
 static void compute_avercos(int n, rvec dip[], real *dd, rvec axis, gmx_bool bPairs)
 {
     int    i, j, k;
-    double dc, dc1, d, n5, ddc1, ddc2, ddc3;
+    double dc, d, ddc1, ddc2, ddc3;
     rvec   xxx = { 1, 0, 0 };
     rvec   yyy = { 0, 1, 0 };
     rvec   zzz = { 0, 0, 1 };
@@ -779,19 +779,18 @@ static void do_dip(t_topology *top, int ePBC, real volume,
     t_enxframe   *fr;
     int           nframes = 1000, nre, timecheck = 0, ncolour = 0;
     ener_file_t   fmu     = NULL;
-    int           i, j, k, n, m, natom = 0, nmol, gnx_tot, teller, tel3;
+    int           i, n, m, natom = 0, gnx_tot, teller, tel3;
     t_trxstatus  *status;
-    int          *dipole_bin, ndipbin, ibin, iVol, step, idim = -1;
+    int          *dipole_bin, ndipbin, ibin, iVol, idim = -1;
     unsigned long mode;
-    char          buf[STRLEN];
-    real          rcut = 0, t, t0, t1, dt, lambda, dd, rms_cos;
+    real          rcut = 0, t, t0, t1, dt, dd, rms_cos;
     rvec          dipaxis;
     matrix        box;
     gmx_bool      bCorr, bTotal, bCont;
     double        M_diff = 0, epsilon, invtel, vol_aver;
     double        mu_ave, mu_mol, M2_ave = 0, M_ave2 = 0, M_av[DIM], M_av2[DIM];
     double        M[3], M2[3], M4[3], Gk = 0, g_k = 0;
-    gmx_stats_t   Mx, My, Mz, Msq, Vol, *Qlsq, mulsq, muframelsq = NULL;
+    gmx_stats_t  *Qlsq, mulsq, muframelsq = NULL;
     ivec          iMu;
     real        **muall        = NULL;
     rvec         *slab_dipoles = NULL;
@@ -996,9 +995,8 @@ static void do_dip(t_topology *top, int ePBC, real volume,
     }
 
     /* Calculate spacing for dipole bin (simple histogram) */
-    ndipbin = 1+(mu_max/0.01);
+    ndipbin = 1 + static_cast<int>(mu_max/0.01);
     snew(dipole_bin, ndipbin);
-    epsilon    = 0.0;
     mu_ave     = 0.0;
     for (m = 0; (m < DIM); m++)
     {
@@ -1016,7 +1014,7 @@ static void do_dip(t_topology *top, int ePBC, real volume,
     gpbc = gmx_rmpbc_init(&top->idef, ePBC, natom);
 
     /* Start while loop over frames */
-    t1     = t0 = t;
+    t0     = t;
     teller = 0;
     do
     {
@@ -1068,7 +1066,7 @@ static void do_dip(t_topology *top, int ePBC, real volume,
             {
                 for (i = 0; (i < gnx[n]); i++)
                 {
-                    int gi, ind0, ind1;
+                    int ind0, ind1;
 
                     ind0  = mols->index[molindex[n][i]];
                     ind1  = mols->index[molindex[n][i]+1];
@@ -1393,7 +1391,7 @@ static void do_dip(t_topology *top, int ePBC, real volume,
     }
     if (!bMU)
     {
-        real aver, sigma, error, lsq;
+        real aver, sigma, error;
 
         gmx_stats_get_ase(mulsq, &aver, &sigma, &error);
         printf("\nDipole moment (Debye)\n");
@@ -1403,7 +1401,6 @@ static void do_dip(t_topology *top, int ePBC, real volume,
         if (bQuad)
         {
             rvec a, s, e;
-            int  mm;
             for (m = 0; (m < DIM); m++)
             {
                 gmx_stats_get_ase(mulsq, &(a[m]), &(s[m]), &(e[m]));
@@ -1530,7 +1527,7 @@ int gmx_dipoles(int argc, char *argv[])
     };
     real           mu_max     = 5, mu_aver = -1, rcmax = 0;
     real           epsilonRF  = 0.0, temp = 300;
-    gmx_bool       bAverCorr  = FALSE, bMolCorr = FALSE, bPairs = TRUE, bPhi = FALSE, bQuad = FALSE;
+    gmx_bool       bPairs = TRUE, bPhi = FALSE, bQuad = FALSE;
     const char    *corrtype[] = {NULL, "none", "mol", "molsep", "total", NULL};
     const char    *axtitle    = "Z";
     int            nslices    = 10; /* nr of slices defined       */
@@ -1577,7 +1574,7 @@ int gmx_dipoles(int argc, char *argv[])
     int            nFF[2];
     atom_id      **grpindex;
     char         **grpname = NULL;
-    gmx_bool       bCorr, bGkr, bMU, bSlab;
+    gmx_bool       bGkr, bMU, bSlab;
     t_filenm       fnm[] = {
         { efEDR, "-en", NULL,         ffOPTRD },
         { efTRX, "-f", NULL,           ffREAD },
@@ -1633,7 +1630,6 @@ int gmx_dipoles(int argc, char *argv[])
              opt2parg_bSet("-axis", asize(pa), pa));
     if (bMU)
     {
-        bAverCorr = TRUE;
         if (bQuad)
         {
             printf("WARNING: Can not determine quadrupoles from energy file\n");
index 7d6c087157059471c08321ab0b0fa5c969c507ac..21351358d37c8575e008038a13f182f632d08adf 100644 (file)
 #include "typedefs.h"
 #include "interf.h"
 
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
 extern void powerspectavg(real ***interface, int t, int xbins, int ybins,
                           char **outfiles);
 
 extern void powerspectavg_intf(t_interf ***if1, t_interf ***if2, int t,
                                int xbins, int ybins, char **outfiles);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
index 23aa493db585568c5808b5a6bcd952e3759bdaf9..8aab4c436af5cdc6cedec5417dcd5dfbd3472b7e 100644 (file)
 #include "corewrap.h"
 #endif
 
-
-/* Portable version of ctime_r implemented in src/gmxlib/string2.c, but we do not want it declared in public installed headers */
-char *
-gmx_ctime_r(const time_t *clock, char *buf, int n);
-
-
 #define CPT_MAGIC1 171817
 #define CPT_MAGIC2 171819
 #define CPTSTRLEN 1024
similarity index 97%
rename from src/gromacs/gmxlib/main.c
rename to src/gromacs/gmxlib/main.cpp
index 05b262d5c40ffb7036e62ec89d8c7215edba7354..1784c29ab1fea2a4dbea7041fc7aff5a45d706d3 100644 (file)
 #include <process.h>
 #endif
 
-
-/* Portable version of ctime_r implemented in src/gmxlib/string2.c, but we do not want it declared in public installed headers */
-char *
-gmx_ctime_r(const time_t *clock, char *buf, int n);
-
-
 #define BUFSIZE 1024
 
 
@@ -88,8 +82,6 @@ static void par_fn(char *base, int ftp, const t_commrec *cr,
                    gmx_bool bAppendSimId, gmx_bool bAppendNodeId,
                    char buf[], int bufsize)
 {
-    int n;
-
     if ((size_t)bufsize < (strlen(base)+10))
     {
         gmx_mem("Character buffer too small!");
@@ -252,7 +244,7 @@ char *gmx_gethostname(char *name, size_t len)
 void gmx_log_open(const char *lognm, const t_commrec *cr, gmx_bool bMasterOnly,
                   gmx_bool bAppendFiles, FILE** fplog)
 {
-    int    len, testlen, pid;
+    int    len, pid;
     char   buf[256], host[256];
     time_t t;
     char   timebuf[STRLEN];
@@ -400,8 +392,8 @@ void init_multisystem(t_commrec *cr, int nsim, char **multidirs,
     char            buf[256];
 #ifdef GMX_MPI
     MPI_Group       mpi_group_world;
-#endif
     int            *rank;
+#endif
 
 #ifndef GMX_MPI
     if (nsim > 1)
@@ -478,7 +470,6 @@ void init_multisystem(t_commrec *cr, int nsim, char **multidirs,
 
     if (multidirs)
     {
-        int ret;
         if (debug)
         {
             fprintf(debug, "Changing to directory %s\n", multidirs[cr->ms->sim]);
@@ -509,15 +500,11 @@ void init_multisystem(t_commrec *cr, int nsim, char **multidirs,
 t_commrec *init_par(int gmx_unused *argc, char ***argv_ptr)
 {
     t_commrec    *cr;
-    char        **argv;
-    int           i;
-    gmx_bool      pe = FALSE;
 
     snew(cr, 1);
 
-    argv = argv_ptr ? *argv_ptr : NULL;
-
 #if defined GMX_MPI && !defined GMX_THREAD_MPI
+    char **argv = argv_ptr ? *argv_ptr : NULL;
     cr->sim_nodeid = gmx_setup(argc, argv, &cr->nnodes);
 
     if (!PAR(cr) && (cr->sim_nodeid != 0))
index 46b34640a059870840f6a8c453719a4e178abd2c..c857856bb0dfd244e2891b531c1cee42b22b6458 100644 (file)
@@ -749,6 +749,12 @@ gmx_bool gmx_isfinite(real x)
     return returnval;
 }
 
+gmx_bool gmx_isnan(real x)
+{
+    /* cppcheck-suppress duplicateExpression */
+    return x != x;
+}
+
 gmx_bool
 check_int_multiply_for_overflow(gmx_large_int_t  a,
                                 gmx_large_int_t  b,
similarity index 98%
rename from src/gromacs/gmxlib/matio.c
rename to src/gromacs/gmxlib/matio.cpp
index f13351cc2fef5eb5b60aa3a3e59533182209f0d2..7ab142ba7bfde8974b542e98e50b80b7c51b99b2 100644 (file)
@@ -38,6 +38,9 @@
 
 #include <stdio.h>
 #include <ctype.h>
+
+#include <algorithm>
+
 #include "sysstuff.h"
 #include "futil.h"
 #include "string2.h"
@@ -283,7 +286,7 @@ void read_xpm_entry(FILE *in, t_matrix *mm)
 {
     t_mapping   *map;
     char        *line_buf = NULL, *line = NULL, *str, buf[256] = {0};
-    int          i, m, col_len, nch, n_axis_x, n_axis_y, llmax;
+    int          i, m, col_len, nch = 0, n_axis_x, n_axis_y, llmax;
     int          llalloc = 0;
     unsigned int r, g, b;
     double       u;
@@ -351,7 +354,7 @@ void read_xpm_entry(FILE *in, t_matrix *mm)
             {
                 gmx_fatal(FARGS, "Dimensions of xpm-file have to be larger than 0\n");
             }
-            llmax        = max(STRLEN, mm->nx+10);
+            llmax        = std::max(STRLEN, mm->nx+10);
             bGetOnWithIt = TRUE;
         }
     }
@@ -360,6 +363,10 @@ void read_xpm_entry(FILE *in, t_matrix *mm)
         fprintf(debug, "mm->nx %d mm->ny %d mm->nmap %d nch %d\n",
                 mm->nx, mm->ny, mm->nmap, nch);
     }
+    if (nch == 0)
+    {
+        gmx_fatal(FARGS, "Number of characters per pixel not found in xpm\n");
+    }
 
     /* Read color map */
     snew(map, mm->nmap);
@@ -441,7 +448,6 @@ void read_xpm_entry(FILE *in, t_matrix *mm)
     /* Read axes, if there are any */
     n_axis_x     = 0;
     n_axis_y     = 0;
-    bGetOnWithIt = FALSE;
     bSetLine     = FALSE;
     do
     {
@@ -659,7 +665,8 @@ static int calc_nmid(int nlevels, real lo, real mid, real hi)
 {
     /* Take care that we have at least 1 entry in the mid to hi range
      */
-    return min(max(0, ((mid-lo)/(hi-lo))*(nlevels-1)), nlevels-1);
+    return std::min(std::max(0, static_cast<int>(((mid-lo)/(hi-lo))*(nlevels-1))),
+                    nlevels-1);
 }
 
 void write_xpm_map3(FILE *out, int n_x, int n_y, int *nlevels,
@@ -766,7 +773,7 @@ static void pr_discrete_cmap(FILE *out, int *nlevel, int i0)
 
     int    i, n;
 
-    *nlevel = min(16, *nlevel);
+    *nlevel = std::min(16, *nlevel);
     n       = *nlevel;
     for (i = 0; (i < n); i++)
     {
@@ -789,8 +796,7 @@ void write_xpm_map_split(FILE *out, int n_x, int n_y,
                          int *nlevel_bot, real lo_bot, real hi_bot,
                          t_rgb rlo_bot, t_rgb rhi_bot)
 {
-    int    i, ntot;
-    real   r, g, b, fac;
+    int    ntot;
 
     ntot = *nlevel_top + *nlevel_bot;
     if (ntot > NMAP)
similarity index 98%
rename from src/gromacs/gmxlib/xvgr.c
rename to src/gromacs/gmxlib/xvgr.cpp
index 24d95984477032dad7630100a453f246cb84f78f..4dff38347927bf53304fcf59d89bce61c3eebd32 100644 (file)
 #include "vec.h"
 #include "gmxfio.h"
 
-/* Portable version of ctime_r implemented in src/gmxlib/string2.c, but we do not want it declared in public installed headers */
-char *
-gmx_ctime_r(const time_t *clock, char *buf, int n);
-
-
 gmx_bool output_env_get_print_xvgr_codes(const output_env_t oenv)
 {
     int xvg_format;
@@ -284,7 +279,6 @@ FILE *xvgropen_type(const char *fn, const char *title, const char *xaxis,
                     const output_env_t oenv)
 {
     FILE  *fp;
-    time_t t;
 
     fp = gmx_fio_fopen(fn, "w");
 
@@ -441,7 +435,6 @@ void xvgr_box(FILE *out,
 /* reads a line into ptr, adjusting len and renewing ptr if neccesary */
 static char *fgets3(FILE *fp, char **ptr, int *len, int maxlen)
 {
-    char *p;
     int   len_remaining = *len; /* remaining amount of allocated bytes in buf */
     int   curp          = 0;    /* current position in buf to read into */
 
@@ -551,7 +544,7 @@ int read_xvg_legend(const char *fn, double ***y, int *ny,
                     char **subtitle, char ***legend)
 {
     FILE    *fp;
-    char    *ptr, *ptr0, *ptr1;
+    char    *ptr;
     char    *base = NULL;
     char    *fmt  = NULL;
     int      k, line = 0, nny, nx, maxx, rval, legend_nalloc, set, nchar;
@@ -738,7 +731,7 @@ real **read_xvg_time(const char *fn,
     char       line0[MAXLINELEN];
     char      *line;
     int        t_nalloc, *val_nalloc, a, narg, n, sin, set, nchar;
-    double     dbl, tend = 0;
+    double     dbl;
     gmx_bool   bEndOfSet, bTimeInRange, bFirstLine = TRUE;
     real     **val;
 
index c50ad9e6cb5295d09e715520c5511f963f554477..db57c809d0d01a1284fe9283fc54cbf32abea2fd 100644 (file)
@@ -1,3 +1,3 @@
-file(GLOB GMXPREPROCESS_SOURCES *.c)
+file(GLOB GMXPREPROCESS_SOURCES *.c *.cpp)
 
 set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${GMXPREPROCESS_SOURCES} PARENT_SCOPE)
index 355625e2192d734f28fde977b6a7e43bd0097041..a6f52f35ee5881076d42965810b39d8660269ea8 100644 (file)
 #include "typedefs.h"
 #include "pdb2top.h"
 
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
 extern void add_param(t_params *ps, int ai, int aj, real *c, char *s);
 
 extern void add_imp_param(t_params *ps, int ai, int aj, int ak, int al,
@@ -65,4 +70,8 @@ extern void add_vsite4_atoms(t_params *ps, int ai, int aj, int ak, int al,
 
 extern int search_jtype(t_restp *rp, char *name, gmx_bool bFirstRes);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif  /* _add_par_h */
index 19e889f4da78e7927eb2f7b657a9d417fc628318..ffd8f4f1b70fb264d4f2003acf51c52ce9abe9e3 100644 (file)
 #include "gpp_atomtype.h"
 #include "hackblock.h"
 
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
 /* stuff for pdb2gmx */
 
 extern void do_vsites(int nrtp, t_restp rtp[], gpp_atomtype_t atype,
@@ -52,4 +57,8 @@ extern void do_vsites(int nrtp, t_restp rtp[], gpp_atomtype_t atype,
 extern void do_h_mass(t_params *psb, int vsite_type[], t_atoms *at, real mHmult,
                       gmx_bool bDeuterate);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif  /* _gen_vsite_h */
similarity index 97%
rename from src/gromacs/gmxpreprocess/pdb2top.c
rename to src/gromacs/gmxpreprocess/pdb2top.cpp
index 0237afc893e333396856289de1dbe6b93635103b..b4815c43f5de13c3ea396f38fddc79ed71df510e 100644 (file)
@@ -75,7 +75,7 @@ static int missing_atoms(t_restp *rp, int resind, t_atoms *at, int i0, int i)
 {
     int      j, k, nmiss;
     char    *name;
-    gmx_bool bFound, bRet;
+    gmx_bool bFound;
 
     nmiss = 0;
     for (j = 0; j < rp->natom; j++)
@@ -294,13 +294,14 @@ choose_ff(const char *ffsel,
         }
         sfree(desc);
 
+        sel = -1;
         do
         {
             pret = fgets(buf, STRLEN, stdin);
 
             if (pret != NULL)
             {
-                sscanf(buf, "%d", &sel);
+                sel = strtol(buf, NULL, 10);
                 sel--;
             }
         }
@@ -408,13 +409,14 @@ void choose_watermodel(const char *wmsel, const char *ffdir,
     ffclose(fp);
     fprintf(stderr, "%2d: %s\n", nwm+1, "None");
 
+    sel = -1;
     do
     {
         pret = fgets(buf, STRLEN, stdin);
 
         if (pret != NULL)
         {
-            sscanf(buf, "%d", &sel);
+            sel = strtol(buf, NULL, 10);
             sel--;
         }
     }
@@ -441,14 +443,13 @@ static int name2type(t_atoms *at, int **cgnr, gpp_atomtype_t atype,
 {
     int         i, j, prevresind, resind, i0, prevcg, cg, curcg;
     char       *name;
-    gmx_bool    bProt, bNterm;
+    gmx_bool    bNterm;
     double      qt;
     int         nmissat;
 
     nmissat = 0;
 
     resind = -1;
-    bProt  = FALSE;
     bNterm = FALSE;
     i0     = 0;
     snew(*cgnr, at->nr);
@@ -463,6 +464,7 @@ static int name2type(t_atoms *at, int **cgnr, gpp_atomtype_t atype,
         prevresind = resind;
         if (at->atom[i].resind != resind)
         {
+            gmx_bool bProt;
             resind = at->atom[i].resind;
             bProt  = gmx_residuetype_is_protein(rt, *(at->resinfo[resind].name));
             bNterm = bProt && (resind == 0);
@@ -545,7 +547,6 @@ void print_top_comment(FILE       *out,
                        const char *ffdir,
                        gmx_bool    bITP)
 {
-    char  tmp[256];
     char  ffdir_parent[STRLEN];
     char *p;
 
@@ -800,9 +801,9 @@ static void at2bonds(t_params *psb, t_hackblock *hb,
              * for missing atoms in bonds, as the hydrogens and terminal atoms
              * have not been added yet.
              */
-            ai = search_atom(hb[resind].rb[ebtsBONDS].b[j].AI, i, atoms,
+            ai = search_atom(hb[resind].rb[ebtsBONDS].b[j].a[0], i, atoms,
                              ptr, TRUE);
-            aj = search_atom(hb[resind].rb[ebtsBONDS].b[j].AJ, i, atoms,
+            aj = search_atom(hb[resind].rb[ebtsBONDS].b[j].a[1], i, atoms,
                              ptr, TRUE);
             if (ai != NO_ATID && aj != NO_ATID)
             {
@@ -827,7 +828,7 @@ static void at2bonds(t_params *psb, t_hackblock *hb,
             {
                 if ( ( hb[resind].hack[j].tp > 0 ||
                        hb[resind].hack[j].oname == NULL ) &&
-                     strcmp(hb[resind].hack[j].AI, *(atoms->atomname[i])) == 0)
+                     strcmp(hb[resind].hack[j].a[0], *(atoms->atomname[i])) == 0)
                 {
                     switch (hb[resind].hack[j].tp)
                     {
@@ -857,10 +858,10 @@ static int pcompar(const void *a, const void *b)
     pa = (t_param *)a;
     pb = (t_param *)b;
 
-    d = pa->AI - pb->AI;
+    d = pa->a[0] - pb->a[0];
     if (d == 0)
     {
-        d = pa->AJ - pb->AJ;
+        d = pa->a[1] - pb->a[1];
     }
     if (d == 0)
     {
@@ -882,11 +883,11 @@ static void clean_bonds(t_params *ps)
         /* swap atomnumbers in bond if first larger than second: */
         for (i = 0; (i < ps->nr); i++)
         {
-            if (ps->param[i].AJ < ps->param[i].AI)
+            if (ps->param[i].a[1] < ps->param[i].a[0])
             {
-                a               = ps->param[i].AI;
-                ps->param[i].AI = ps->param[i].AJ;
-                ps->param[i].AJ = a;
+                a                 = ps->param[i].a[0];
+                ps->param[i].a[0] = ps->param[i].a[1];
+                ps->param[i].a[1] = a;
             }
         }
 
@@ -897,8 +898,8 @@ static void clean_bonds(t_params *ps)
         j = 1;
         for (i = 1; (i < ps->nr); i++)
         {
-            if ((ps->param[i].AI != ps->param[j-1].AI) ||
-                (ps->param[i].AJ != ps->param[j-1].AJ) )
+            if ((ps->param[i].a[0] != ps->param[j-1].a[0]) ||
+                (ps->param[i].a[1] != ps->param[j-1].a[1]) )
             {
                 if (j != i)
                 {
@@ -1031,10 +1032,8 @@ void get_hackblocks_rtp(t_hackblock **hb, t_restp **restp,
     int         i, j, k, l;
     char       *key;
     t_restp    *res;
-    char        buf[STRLEN];
-    const char *Hnum = "123456";
     int         tern, terc;
-    gmx_bool    bN, bC, bRM;
+    gmx_bool    bRM;
 
     snew(*hb, nres);
     snew(*restp, nres);
@@ -1114,7 +1113,7 @@ void get_hackblocks_rtp(t_hackblock **hb, t_restp **restp,
                 for (l = 0; l < (*restp)[i].natom; l++)
                 {
                     if ( ( (*hb)[i].hack[j].oname == NULL &&
-                           strcmp((*hb)[i].hack[j].AI, *(*restp)[i].atomname[l]) == 0 ) ||
+                           strcmp((*hb)[i].hack[j].a[0], *(*restp)[i].atomname[l]) == 0 ) ||
                          ( (*hb)[i].hack[j].oname != NULL &&
                            strcmp((*hb)[i].hack[j].oname, *(*restp)[i].atomname[l]) == 0 ) )
                     {
@@ -1139,7 +1138,7 @@ void get_hackblocks_rtp(t_hackblock **hb, t_restp **restp,
                                   "atom %s not found in buiding block %d%s "
                                   "while combining tdb and rtp",
                                   (*hb)[i].hack[j].oname != NULL ?
-                                  (*hb)[i].hack[j].oname : (*hb)[i].hack[j].AI,
+                                  (*hb)[i].hack[j].oname : (*hb)[i].hack[j].a[0],
                                   i+1, *resinfo[i].rtp);
                     }
                 }
@@ -1234,7 +1233,7 @@ static gmx_bool match_atomnames_with_rtp_atom(t_atoms *pdba, rvec *x, int atind,
                                               gmx_bool bVerbose)
 {
     int      resnr;
-    int      i, j, k;
+    int      j, k;
     char    *oldnm, *newnm;
     int      anmnr;
     char    *start_at, buf[STRLEN];
@@ -1390,20 +1389,13 @@ void match_atomnames_with_rtp(t_restp restp[], t_hackblock hb[],
                               t_atoms *pdba, rvec *x,
                               gmx_bool bVerbose)
 {
-    int          i, j, k;
-    char        *oldnm, *newnm;
-    int          resnr;
+    int          i, j;
+    char        *oldnm;
     t_restp     *rptr;
-    t_hackblock *hbr;
-    int          anmnr;
-    char        *start_at, buf[STRLEN];
-    int          start_nr;
-    gmx_bool     bFoundInAdd;
 
     for (i = 0; i < pdba->nr; i++)
     {
         oldnm = *pdba->atomname[i];
-        resnr = pdba->resinfo[pdba->atom[i].resind].nr;
         rptr  = &restp[pdba->atom[i].resind];
         for (j = 0; (j < rptr->natom); j++)
         {
index bedc68468de89683a39516d607c94e83b7b04b47..e193ee10ee0a2c8a06a67dc41c947722a4584007 100644 (file)
 
 #include "typedefs.h"
 
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
 extern atom_id search_atom(const char *type, int start,
                            t_atoms *atoms,
                            const char *bondtype, gmx_bool bAllowMissing);
@@ -50,4 +55,8 @@ extern atom_id search_atom(const char *type, int start,
 
 extern void set_at(t_atom *at, real m, real q, int type, int resind);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif  /* _pgutil_h */
index a0221554e59192f715a36bdd6e06451e69116da0..666f5eae7f15af1b2e69ef7bbdde9a88da680595 100644 (file)
@@ -100,6 +100,13 @@ enum {
                         * make a rest group for the remaining particles.    */
 };
 
+static const char *constraints[eshNR+1]    = {
+    "none", "h-bonds", "all-bonds", "h-angles", "all-angles", NULL
+};
+
+static const char *couple_lam[ecouplamNR+1]    = {
+    "vdw-q", "vdw", "q", "none", NULL
+};
 
 void init_ir(t_inputrec *ir, t_gromppopts *opts)
 {
index 4bf1c5334fba8057e92f49f0d595ebd5d43a7577..613d9b878db5150981132cecf6f7be617646c558 100644 (file)
@@ -45,18 +45,10 @@ enum {
     eshNONE, eshHBONDS, eshALLBONDS, eshHANGLES, eshALLANGLES, eshNR
 };
 
-static const char *constraints[eshNR+1]    = {
-    "none", "h-bonds", "all-bonds", "h-angles", "all-angles", NULL
-};
-
 enum {
     ecouplamVDWQ, ecouplamVDW, ecouplamQ, ecouplamNONE, ecouplamNR
 };
 
-static const char *couple_lam[ecouplamNR+1]    = {
-    "vdw-q", "vdw", "q", "none", NULL
-};
-
 typedef struct {
     int      warnings;
     int      nshake;
index ff049e32bac78ee6860bc8c191c00d6610d4a249..17889d75e87f7853fae8d8318a8a94db9be3b5e4 100644 (file)
 
 #include "grompp.h"
 
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
 typedef struct tagDirStack {
     directive           d;
     struct tagDirStack *prev;
@@ -59,4 +64,8 @@ extern int  DS_Search (DirStack *DS, directive d);
 
 extern int  DS_Check_Order (DirStack *DS, directive d);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif  /* _topdirs_h */
index 854f10df33aa1c7c97c755fd1a5ac771b5ac4ac8..567119624b489ece0f85d1a970f5ec65d3f617fa 100644 (file)
@@ -97,6 +97,7 @@ float   gmx_erfcf(float x);
 #endif
 
 gmx_bool gmx_isfinite(real x);
+gmx_bool gmx_isnan(real x);
 
 /*! \brief Check if two numbers are within a tolerance
  *
index 16bc1b4137fab4aa55f2c8a98d23fa2dd3b0d3f6..6f6fc9c14a0ea2a1016bfbb052a9708d2c443d88 100644 (file)
 #include "toputil.h"
 #include "hackblock.h"
 
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
 /* this *MUST* correspond to array in pdb2top.c */
 enum {
     ehisA, ehisB, ehisH, ehis1, ehisNR
@@ -120,5 +125,8 @@ void pdb2top(FILE *top_file, char *posre_fn, char *molname,
 
 void print_sums(t_atoms *atoms, gmx_bool bSystem);
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif  /* _pdb2top_h */
index b7f9b4ad28ea09e56129ea994cdfb8e638946e89..72869c387893bf2a661fc4bf741831073508f5c0 100644 (file)
@@ -152,52 +152,55 @@ void save_free_aligned(const char *name, const char *file, int line, void *ptr);
 
 /* Use of sizeof(T) in _snew() and _srenew() can cause obscure bugs if
  * several files define distinct data structures with identical names and
- * allocate memory for them using the macros below.
- * For this reason, the size of an element is passed as a parameter.
- *
+ * allocate memory for them using the macros below.  Note that by the standard,
+ * such declarations cause undefined behavior.
  * The C versions work fine in such cases, but when compiled with a C++
  * compiler (and if the compiler does not inline the calls), the linker cannot
  * tell that data structures with identical names are actually different and
  * links calls to these template functions incorrectly, which can result in
  * allocation of an incorrect amount of memory if the element size is computed
- * within the function. Even with the size passed as a parameter, incorrect
- * linkage will occur, but as the type is now only present in the cast, it
- * should not cause problems.
+ * within the function.
+ *
+ * This could be solved by passing the size as a parameter, but this has other
+ * issues: it provokes warnings from cppcheck for some invokations.
+ * Even with the size passed as a parameter, incorrect linkage will occur.
+ * When converting files to C++, locally declared structs should be enclosed in
+ * anonymous namespaces or some other means taken to ensure they are unique.
  */
-template <typename T>
+template <typename T> inline
 void _snew(const char *name, const char *file, int line,
-           T * &ptr, size_t nelem, size_t elsize)
+           T * &ptr, size_t nelem)
 {
-    ptr = (T *)save_calloc(name, file, line, nelem, elsize);
+    ptr = (T *)save_calloc(name, file, line, nelem, sizeof(T));
 }
-template <typename T>
+template <typename T> inline
 void _srenew(const char *name, const char *file, int line,
-             T * &ptr, size_t nelem, size_t elsize)
+             T * &ptr, size_t nelem)
 {
-    ptr = (T *)save_realloc(name, file, line, ptr, nelem, elsize);
+    ptr = (T *)save_realloc(name, file, line, ptr, nelem, sizeof(T));
 }
-template <typename T>
+template <typename T> inline
 void _smalloc(const char *name, const char *file, int line, T * &ptr, size_t size)
 {
     ptr = (T *)save_malloc(name, file, line, size);
 }
-template <typename T>
+template <typename T> inline
 void _srealloc(const char *name, const char *file, int line, T * &ptr, size_t size)
 {
     ptr = (T *)save_realloc(name, file, line, ptr, size, sizeof(char));
 }
-template <typename T>
+template <typename T> inline
 void _snew_aligned(const char *name, const char *file, int line,
-                   T * &ptr, size_t nelem, size_t elsize, size_t alignment)
+                   T * &ptr, size_t nelem, size_t alignment)
 {
-    ptr = (T *)save_calloc_aligned(name, file, line, nelem, elsize, alignment);
+    ptr = (T *)save_calloc_aligned(name, file, line, nelem, sizeof(T), alignment);
 }
 
-#define snew(ptr, nelem) _snew(#ptr, __FILE__, __LINE__, (ptr), (nelem), sizeof(*(ptr)))
-#define srenew(ptr, nelem) _srenew(#ptr, __FILE__, __LINE__, (ptr), (nelem), sizeof(*(ptr)))
+#define snew(ptr, nelem) _snew(#ptr, __FILE__, __LINE__, (ptr), (nelem))
+#define srenew(ptr, nelem) _srenew(#ptr, __FILE__, __LINE__, (ptr), (nelem))
 #define smalloc(ptr, size) _smalloc(#ptr, __FILE__, __LINE__, (ptr), (size))
 #define srealloc(ptr, size) _srealloc(#ptr, __FILE__, __LINE__, (ptr), (size))
-#define snew_aligned(ptr, nelem, alignment) _snew_aligned(#ptr, __FILE__, __LINE__, (ptr), (nelem), sizeof(*(ptr)), alignment)
+#define snew_aligned(ptr, nelem, alignment) _snew_aligned(#ptr, __FILE__, __LINE__, (ptr), (nelem), alignment)
 
 #else /* __cplusplus */
 
index b29861b9d168fff2e288802fd1958dd76e6153cb..4a847426f827e0b3b9b5b65d32776f2c8367fec2 100644 (file)
@@ -115,6 +115,9 @@ void rtrim(char *str);
 /** Remove leading and trailing whitespace from a string. */
 void trim(char *str);
 
+/** Portable version of ctime_r. */
+char *gmx_ctime_r(const time_t *clock, char *buf, int n);
+
 /** Prints creation time stamp and user information into a file as comments. */
 void nice_header(FILE *out, const char *fn);
 
index 9956e9019b79b4da9a647245d2982cfe2089a6bb..9df66ff50d1d71066ec956a63c4be0d1a0c94368 100644 (file)
@@ -99,10 +99,10 @@ int over_alloc_dd(int n);
  */
 
 /* Over allocation for small data types: int, real etc. */
-#define over_alloc_small(n) (OVER_ALLOC_FAC*(n) + 8000)
+#define over_alloc_small(n) (int)(OVER_ALLOC_FAC*(n) + 8000)
 
 /* Over allocation for large data types: complex structs */
-#define over_alloc_large(n) (OVER_ALLOC_FAC*(n) + 1000)
+#define over_alloc_large(n) (int)(OVER_ALLOC_FAC*(n) + 1000)
 
 int gmx_large_int_to_int(gmx_large_int_t step, const char *warn);
 /* Convert a gmx_large_int_t value to int.
index 5723a848db68dc970ef8068ac8afa0285abbd7d8..a00886e26fc2453bfd5ef4cf9cc9f183b10dfa5d 100644 (file)
 #include "nbnxn_cuda_data_mgmt.h"
 #include "nbnxn_cuda/nbnxn_cuda.h"
 
-#if 0
-typedef struct gmx_timeprint {
-
-} t_gmx_timeprint;
-#endif
-
-/* Portable version of ctime_r implemented in src/gmxlib/string2.c, but we do not want it declared in public installed headers */
-char *
-gmx_ctime_r(const time_t *clock, char *buf, int n);
-
-
 double
 gmx_gettime()
 {
index 98a3ca4e3a653de8802fe0376f188eeedf4dd72f..10ec04a8307ae505569992b5462abaf84d1c3184 100644 (file)
@@ -83,8 +83,12 @@ if (CPPCHECK_EXECUTABLE AND UNIX)
         --suppress=missingInclude:src/programs/mdrun/gmx_gpu_utils/gmx_gpu_utils.cu
         --inline-suppr)
     set(_cxx_flags
+        -D__cplusplus
         --suppress=variableScope
         --suppress=unnecessaryForwardDeclaration
+        --suppress=invalidscanf:src/gromacs/gmxlib/matio.cpp
+        --suppress=invalidscanf:src/gromacs/gmxlib/xvgr.cpp
+        --suppress=invalidscanf:src/gromacs/gmxpreprocess/pdb2top.cpp
         --suppress=*:src/gromacs/selection/scanner.cpp)
 
     # This list will hold the list of all files with cppcheck errors