Commit 1d2a43c0 authored by Peter W. Draper's avatar Peter W. Draper

Fixes so that tests compile with g++

parent 1ef15711
......@@ -315,8 +315,9 @@ void writeArray(const struct engine* e, hid_t grp, char* fileName,
* @todo Read snapshots distributed in more than one file.
*
*/
void read_ic_single(char* fileName, const struct unit_system* internal_units,
double dim[3], struct part** parts, struct gpart** gparts,
void read_ic_single(const char* fileName,
const struct unit_system* internal_units, double dim[3],
struct part** parts, struct gpart** gparts,
struct spart** sparts, size_t* Ngas, size_t* Ngparts,
size_t* Nstars, int* periodic, int* flag_entropy,
int with_hydro, int with_gravity, int with_stars,
......
......@@ -29,8 +29,9 @@
#include "part.h"
#include "units.h"
void read_ic_single(char* fileName, const struct unit_system* internal_units,
double dim[3], struct part** parts, struct gpart** gparts,
void read_ic_single(const char* fileName,
const struct unit_system* internal_units, double dim[3],
struct part** parts, struct gpart** gparts,
struct spart** sparts, size_t* Ngas, size_t* Ndm,
size_t* Nstars, int* periodic, int* flag_entropy,
int with_hydro, int with_gravity, int with_stars,
......
......@@ -268,7 +268,7 @@ struct cell *make_cell(size_t n, const double offset[3], double size, double h,
const size_t count = n * n * n;
const double volume = size * size * size;
struct cell *cell = malloc(sizeof(struct cell));
struct cell *cell = (struct cell *)malloc(sizeof(struct cell));
bzero(cell, sizeof(struct cell));
if (posix_memalign((void **)&cell->parts, part_align,
......@@ -637,8 +637,8 @@ int main(int argc, char *argv[]) {
main_cell = cells[62];
/* Construct the real solution */
struct solution_part *solution =
malloc(main_cell->count * sizeof(struct solution_part));
struct solution_part *solution = (struct solution_part *)malloc(
main_cell->count * sizeof(struct solution_part));
get_solution(main_cell, solution, rho, vel, press, size);
ticks timings[27];
......
......@@ -98,7 +98,7 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
const size_t count = n * n * n;
const double volume = size * size * size;
float h_max = 0.f;
struct cell *cell = malloc(sizeof(struct cell));
struct cell *cell = (struct cell *)malloc(sizeof(struct cell));
bzero(cell, sizeof(struct cell));
if (posix_memalign((void **)&cell->parts, part_align,
......@@ -502,7 +502,7 @@ int main(int argc, char *argv[]) {
#if defined(TEST_DOSELF_SUBSET) || defined(TEST_DOPAIR_SUBSET)
int *pid = NULL;
int count = 0;
if ((pid = malloc(sizeof(int) * main_cell->count)) == NULL)
if ((pid = (int *)malloc(sizeof(int) * main_cell->count)) == NULL)
error("Can't allocate memory for pid.");
for (int k = 0; k < main_cell->count; k++)
if (part_is_active(&main_cell->parts[k], &engine)) {
......
......@@ -59,7 +59,7 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
const size_t count = n * n * n;
const double volume = size * size * size;
float h_max = 0.f;
struct cell *cell = malloc(sizeof(struct cell));
struct cell *cell = (struct cell *)malloc(sizeof(struct cell));
bzero(cell, sizeof(struct cell));
if (posix_memalign((void **)&cell->parts, part_align,
......
......@@ -38,7 +38,7 @@
void dump_mapper(void *map_data, int num_elements, void *extra_data) {
struct dump *d = (struct dump *)extra_data;
size_t offset;
char *out_string = dump_get(d, 7, &offset);
char *out_string = (char *)dump_get(d, 7, &offset);
char out_buff[8];
/* modulo due to bug in gcc, should be removed */
snprintf(out_buff, 8, "%06zi\n", (offset / 7) % 1000000);
......
......@@ -68,7 +68,8 @@ int main(int argc, char *argv[]) {
gparts[0].mass = 1.f;
/* Read the parameter file */
struct swift_params *params = malloc(sizeof(struct swift_params));
struct swift_params *params =
(struct swift_params *)malloc(sizeof(struct swift_params));
parser_read_file("fft_params.yml", params);
struct cosmology cosmo;
......@@ -116,10 +117,10 @@ int main(int argc, char *argv[]) {
/* Now check that we got the right answer */
int nr_cells = space.nr_cells;
double *r = malloc(nr_cells * sizeof(double));
double *m = malloc(nr_cells * sizeof(double));
double *pot = malloc(nr_cells * sizeof(double));
double *pot_exact = malloc(nr_cells * sizeof(double));
double *r = (double *)malloc(nr_cells * sizeof(double));
double *m = (double *)malloc(nr_cells * sizeof(double));
double *pot = (double *)malloc(nr_cells * sizeof(double));
double *pot_exact = (double *)malloc(nr_cells * sizeof(double));
FILE *file = fopen("potential.dat", "w");
for (int i = 0; i < nr_cells; ++i) {
......
......@@ -63,7 +63,7 @@ void test_log_parts(struct dump *d) {
/* Recover the last part from the dump. */
bzero(&p, sizeof(struct part));
size_t offset_old = offset;
int mask = logger_read_part(&p, &offset, d->data);
int mask = logger_read_part(&p, &offset, (const char *)d->data);
printf(
"Recovered part at offset %#016zx with mask %#04x: p.x[0]=%e, "
"p.v[0]=%e.\n",
......@@ -76,7 +76,7 @@ void test_log_parts(struct dump *d) {
/* Recover the second part from the dump (only position). */
bzero(&p, sizeof(struct part));
offset_old = offset;
mask = logger_read_part(&p, &offset, d->data);
mask = logger_read_part(&p, &offset, (const char *)d->data);
printf(
"Recovered part at offset %#016zx with mask %#04x: p.x[0]=%e, "
"p.v[0]=%e.\n",
......@@ -89,7 +89,7 @@ void test_log_parts(struct dump *d) {
/* Recover the first part from the dump. */
bzero(&p, sizeof(struct part));
offset_old = offset;
mask = logger_read_part(&p, &offset, d->data);
mask = logger_read_part(&p, &offset, (const char *)d->data);
printf(
"Recovered part at offset %#016zx with mask %#04x: p.x[0]=%e, "
"p.v[0]=%e.\n",
......@@ -131,7 +131,7 @@ void test_log_gparts(struct dump *d) {
/* Recover the last part from the dump. */
bzero(&p, sizeof(struct gpart));
size_t offset_old = offset;
int mask = logger_read_gpart(&p, &offset, d->data);
int mask = logger_read_gpart(&p, &offset, (const char *)d->data);
printf(
"Recovered gpart at offset %#016zx with mask %#04x: p.x[0]=%e, "
"p.v[0]=%e.\n",
......@@ -144,7 +144,7 @@ void test_log_gparts(struct dump *d) {
/* Recover the second part from the dump. */
bzero(&p, sizeof(struct gpart));
offset_old = offset;
mask = logger_read_gpart(&p, &offset, d->data);
mask = logger_read_gpart(&p, &offset, (const char *)d->data);
printf(
"Recovered gpart at offset %#016zx with mask %#04x: p.x[0]=%e, "
"p.v[0]=%e.\n",
......@@ -157,7 +157,7 @@ void test_log_gparts(struct dump *d) {
/* Recover the first part from the dump. */
bzero(&p, sizeof(struct gpart));
offset_old = offset;
mask = logger_read_gpart(&p, &offset, d->data);
mask = logger_read_gpart(&p, &offset, (const char *)d->data);
printf(
"Recovered gpart at offset %#016zx with mask %#04x: p.x[0]=%e, "
"p.v[0]=%e.\n",
......@@ -189,7 +189,7 @@ void test_log_timestamps(struct dump *d) {
/* Recover the three timestamps. */
size_t offset_old = offset;
t = 0;
int mask = logger_read_timestamp(&t, &offset, d->data);
int mask = logger_read_timestamp(&t, &offset, (const char *)d->data);
printf("Recovered timestamp %020llu at offset %#016zx with mask %#04x.\n", t,
offset_old, mask);
if (t != 30) {
......@@ -199,7 +199,7 @@ void test_log_timestamps(struct dump *d) {
offset_old = offset;
t = 0;
mask = logger_read_timestamp(&t, &offset, d->data);
mask = logger_read_timestamp(&t, &offset, (const char *)d->data);
printf("Recovered timestamp %020llu at offset %#016zx with mask %#04x.\n", t,
offset_old, mask);
if (t != 20) {
......@@ -209,7 +209,7 @@ void test_log_timestamps(struct dump *d) {
offset_old = offset;
t = 0;
mask = logger_read_timestamp(&t, &offset, d->data);
mask = logger_read_timestamp(&t, &offset, (const char *)d->data);
printf("Recovered timestamp %020llu at offset %#016zx with mask %#04x.\n", t,
offset_old, mask);
if (t != 10) {
......
......@@ -78,7 +78,7 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
enum velocity_types vel) {
const size_t count = n * n * n;
const double volume = size * size * size;
struct cell *cell = malloc(sizeof(struct cell));
struct cell *cell = (struct cell *)malloc(sizeof(struct cell));
bzero(cell, sizeof(struct cell));
if (posix_memalign((void **)&cell->parts, part_align,
......
......@@ -150,8 +150,10 @@ int main(int argc, char *argv[]) {
cj.ti_gravity_end_max = 8;
/* Allocate multipoles */
ci.multipole = malloc(sizeof(struct gravity_tensors));
cj.multipole = malloc(sizeof(struct gravity_tensors));
ci.multipole =
(struct gravity_tensors *)malloc(sizeof(struct gravity_tensors));
cj.multipole =
(struct gravity_tensors *)malloc(sizeof(struct gravity_tensors));
bzero(ci.multipole, sizeof(struct gravity_tensors));
bzero(cj.multipole, sizeof(struct gravity_tensors));
......
......@@ -27,7 +27,7 @@
*/
struct cell *make_cell(size_t N, float cellSize, int offset[3], int id_offset) {
size_t count = N * N * N;
struct cell *cell = malloc(sizeof(struct cell));
struct cell *cell = (struct cell *)malloc(sizeof(struct cell));
bzero(cell, sizeof(struct cell));
struct part *part;
struct xpart *xpart;
......
......@@ -63,10 +63,10 @@ int main(int argc, char *argv[]) {
/* Create a particle */
struct part *parts = NULL;
parts = malloc(sizeof(struct part));
parts = (struct part *)malloc(sizeof(struct part));
bzero(parts, sizeof(struct part));
struct xpart *xparts = NULL;
xparts = malloc(sizeof(struct xpart));
xparts = (struct xpart *)malloc(sizeof(struct xpart));
bzero(xparts, sizeof(struct xpart));
/* Put the particle on the orbit */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment