LLNL / Silo

Mesh and Field I/O Library and Scientific Database
https://silo.llnl.gov
Other
25 stars 22 forks source link

tests: add missing header for `difftime` #371

Open thesamesam opened 3 months ago

thesamesam commented 3 months ago

With GCC 14, which makes implicit function declarations an error by default:

TestReadMask.c: In function ‘ElapsedTime’:
TestReadMask.c:746:15: error: implicit declaration of function ‘difftime’ [-Wimplicit-function-declaration]
  746 |     ms = (int)difftime(end_time.tv_sec, start_time.tv_sec);
      |               ^~~~~~~~
TestReadMask.c:62:1: note: ‘difftime’ is defined in header ‘<time.h>’; this is probably fixable by adding ‘#include <time.h>’
   61 | #include <std.c>
  +++ |+#include <time.h>
   62 |

Fix the include guards and include unconditionally (for difftime) and unconditionally too (for memcpy).

thesamesam commented 3 months ago

I got another failure with GCC 14 (which makes -Wincompatible-pointer-types) an error by default, but I'm not familiar enough with this codebase to fix it correctly:

dir.c:203:44: error: passing argument 4 of ‘DBPutMultimesh’ from incompatible pointer type [-Wincompatible-pointer-types]
  203 |     DBPutMultimesh(dbfile, "mmesh", nmesh, meshnames, meshtypes, NULL);
      |                                            ^~~~~~~~~
      |                                            |
      |                                            char **
In file included from dir.c:64:
./../src/silo/silo.h:2185:84: note: expected ‘const char * const*’ but argument is of type ‘char **’
 2185 | SILO_API extern int                    DBPutMultimesh(DBfile *, char const *, int, char const * const *, int const *,
      |                                                                                    ^~~~~~~~~~~~~~~~~~~~
markcmiller86 commented 3 months ago

Thanks for the PR. Will review and merge early this coming week.

I got another failure with GCC 14 (which makes -Wincompatible-pointer-types) an error by default, but I'm not familiar enough with this codebase to fix it correctly:

Short answer...its missing a cast to DBCAS_t (constant array of strings) as in

DBPutMultimesh(dbfile, "mmesh", nmesh, (DBCAS_t) meshnames, meshtypes, NULL);

For a longer explanation, see these notes.