I have this ProcessStasts.h file that is included into two other .h files.
#pragma once
#include <mpi.h>
#include <cstddef>
struct ProcessStats
{
int rank,
itLeft,
crtIt,
processFlag;
float speed;
};
MPI_Datatype MPI_Cust_ProcessStats_create()
{
// set data to create new MPI data type
MPI_Datatype MPI_Cust_ProcessStats;
MPI_Datatype dataTypes[5] = {MPI_INT, MPI_INT, MPI_INT, MPI_INT, MPI_FLOAT};
int blockLengths[5] = {1, 1, 1, 1, 1};
MPI_Aint offsets[5];
offsets[0] = (MPI_Aint) offsetof(ProcessStats, rank);
offsets[1] = (MPI_Aint) offsetof(ProcessStats, itLeft);
offsets[2] = (MPI_Aint) offsetof(ProcessStats, crtIt);
offsets[3] = (MPI_Aint) offsetof(ProcessStats, processFlag);
offsets[4] = (MPI_Aint) offsetof(ProcessStats, speed);
// create new MPI type based on data from above
MPI_Type_create_struct(5, blockLengths, offsets, dataTypes, &MPI_Cust_ProcessStats);
MPI_Type_commit(&MPI_Cust_ProcessStats);
return MPI_Cust_ProcessStats;
}
When I try compiling I get this error: error LNK2005: MPI_Cust_ProcessStats_create(void) already defined. If I comment the #include "ProcessStasts.h" directive and the line that uses the ProcessStats struct, from one of the files, it compiles correctly. I even tryed to comment all lines dependent in ProcessStats and only leave the #include "ProcessStasts.h" statements and I get this lnk error. What is wrong?
3when you have 5 fields in thestruct?