Fixing compiler warnings

This commit is contained in:
Michael Tryby
2018-09-13 10:48:55 -04:00
parent 735811dd60
commit bec729a669
5 changed files with 35 additions and 34 deletions

View File

@@ -308,7 +308,8 @@ extern "C" {
@param HeadlossFormula headloss formula flag
@return error code
*/
int DLLEXPORT ENinit(char *rptFile, char *binOutFile, int UnitsType, int HeadlossFormula);
int DLLEXPORT ENinit(const char *rptFile, const char *binOutFile,
int UnitsType, int HeadlossFormula);
/**
@brief Opens EPANET input file & reads in network data
@@ -317,14 +318,14 @@ extern "C" {
@param binOutFile pointer to name of binary output file (to be created)
@return error code
*/
int DLLEXPORT ENopen(char *inpFile, char *rptFile, char *binOutFile);
int DLLEXPORT ENopen(const char *inpFile, const char *rptFile, const char *binOutFile);
/**
@brief Saves current data to "INP" formatted text file.
@param filename The file path to create
@return Error code
*/
int DLLEXPORT ENsaveinpfile(char *filename);
int DLLEXPORT ENsaveinpfile(const char *filename);
/**
@brief Frees all memory and files used by EPANET
@@ -1200,13 +1201,13 @@ extern "C" {
//int DLLEXPORT EN_epanet(EN_ProjectHandle ph, const char *f1, const char *f2,
// const char *f3, void(*pviewprog)(char *));
int DLLEXPORT EN_init(EN_ProjectHandle ph, char *rptFile, char *binOutFile,
int DLLEXPORT EN_init(EN_ProjectHandle ph, const char *rptFile, const char *binOutFile,
EN_FlowUnits UnitsType, EN_FormType HeadlossFormula);
int DLLEXPORT EN_open(EN_ProjectHandle ph, const char *inpFile,
const char *rptFile, const char *binOutFile);
int DLLEXPORT EN_saveinpfile(EN_ProjectHandle ph, char *filename);
int DLLEXPORT EN_saveinpfile(EN_ProjectHandle ph, const char *filename);
int DLLEXPORT EN_close(EN_ProjectHandle ph);
int DLLEXPORT EN_solveH(EN_ProjectHandle ph);

View File

@@ -185,7 +185,7 @@ int DLLEXPORT ENepanet(const char *f1, const char *f2, const char *f3, void (*pv
return (errcode);
}
int DLLEXPORT ENinit(char *f2, char *f3, int UnitsType,
int DLLEXPORT ENinit(const char *f2, const char *f3, int UnitsType,
int HeadlossFormula) {
int errcode = 0;
ERRCODE(EN_createproject(&_defaultModel));
@@ -193,14 +193,14 @@ int DLLEXPORT ENinit(char *f2, char *f3, int UnitsType,
return (errcode);
}
int DLLEXPORT ENopen(char *f1, char *f2, char *f3) {
int DLLEXPORT ENopen(const char *f1, const char *f2, const char *f3) {
int errcode = 0;
ERRCODE(EN_createproject(&_defaultModel));
EN_open(_defaultModel, f1, f2, f3);
return (errcode);
}
int DLLEXPORT ENsaveinpfile(char *filename) {
int DLLEXPORT ENsaveinpfile(const char *filename) {
return EN_saveinpfile(_defaultModel, filename);
}
@@ -642,7 +642,7 @@ int DLLEXPORT EN_runproject(EN_ProjectHandle ph, const char *f1, const char *f2,
return errcode;
}
int DLLEXPORT EN_init(EN_ProjectHandle ph, char *f2, char *f3,
int DLLEXPORT EN_init(EN_ProjectHandle ph, const char *f2, const char *f3,
EN_FlowUnits UnitsType, EN_FormType HeadlossFormula)
/*----------------------------------------------------------------
** Input:
@@ -777,7 +777,7 @@ int DLLEXPORT EN_open(EN_ProjectHandle ph, const char *f1, const char *f2, const
return set_error(p->error_handle, errcode);
}
int DLLEXPORT EN_saveinpfile(EN_ProjectHandle ph, char *filename)
int DLLEXPORT EN_saveinpfile(EN_ProjectHandle ph, const char *filename)
/*----------------------------------------------------------------
** Input: filename = name of INP file
** Output: none

View File

@@ -248,6 +248,6 @@ int saveepilog(EN_Project *pr); /* Saves output file epilog
/* ------------ INPFILE.C --------------*/
int saveinpfile(EN_Project *pr, char *); /* Saves network to text file */
int saveinpfile(EN_Project *pr, const char *); /* Saves network to text file */
#endif

View File

@@ -114,7 +114,7 @@ void saveauxdata(parser_data_t *parser, FILE *f)
//// This function was heavily modified. ////
int saveinpfile(EN_Project *pr, char *fname)
int saveinpfile(EN_Project *pr, const char *fname)
/*
-------------------------------------------------
Writes network data to text file.

View File

@@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
error = EN_open(ph, path_inp.c_str(), path_rpt.c_str(), path_out.c_str());
BOOST_REQUIRE(error == 0);
error = EN_getnodeindex(ph, "2", &Nindex);
error = EN_getnodeindex(ph, (char *)"2", &Nindex);
BOOST_REQUIRE(error == 0);
error = EN_openH(ph);
@@ -86,11 +86,11 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
float Y[9] = {70, 70, 70, 70, 40, 40, 40, 10, 10 };
float L[12] = {10530, 5280, 5280, 5280, 5280, 5280, 200, 5280, 5280, 5280, 5280, 5280};
float dia[12] = { 18, 14, 10, 10, 12, 6, 18, 10, 12, 8, 8, 6 };
float P[12] = { 1, 1.2, 1.4, 1.6, 1.4, 1.2, 1, 0.8, 0.6, 0.4, 0.6, 0.8 };
float P[12] = { 1.0f, 1.2f, 1.4f, 1.6f, 1.4f, 1.2f, 1.0f, 0.8f, 0.6f, 0.4f, 0.6f, 0.8f };
error = EN_createproject(&ph);
error = EN_init(ph, "net.rpt", "net.out", EN_GPM, EN_HW);
error = EN_addpattern(ph, "1");
error = EN_addpattern(ph, (char *)"1");
BOOST_REQUIRE(error == 0);
error = EN_setpattern(ph, 1, P, 12);
BOOST_REQUIRE(error == 0);
@@ -107,14 +107,14 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
error = EN_setdemandpattern(ph, i + 1, 1, 1);
BOOST_REQUIRE(error == 0);
}
error = EN_addnode(ph, "9", EN_RESERVOIR);
error = EN_addnode(ph, (char *)"9", EN_RESERVOIR);
BOOST_REQUIRE(error == 0);
error = EN_setcoord(ph, 10, 10, 70);
BOOST_REQUIRE(error == 0);
error = EN_setnodevalue(ph, 10, EN_ELEVATION, 800);
BOOST_REQUIRE(error == 0);
error = EN_addnode(ph, "2", EN_TANK);
error = EN_addnode(ph, (char *)"2", EN_TANK);
BOOST_REQUIRE(error == 0);
error = EN_setcoord(ph, 11, 50, 90);
BOOST_REQUIRE(error == 0);
@@ -131,29 +131,29 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
error = EN_setnodevalue(ph, 11, EN_MIXFRACTION, 1);
BOOST_REQUIRE(error == 0);
error = EN_addlink(ph, "10", EN_PIPE, "10", "11");
error = EN_addlink(ph, (char *)"10", EN_PIPE, (char *)"10", (char *)"11");
BOOST_REQUIRE(error == 0);
error = EN_addlink(ph, "11", EN_PIPE, "11", "12");
error = EN_addlink(ph, (char *)"11", EN_PIPE, (char *)"11", (char *)"12");
BOOST_REQUIRE(error == 0);
error = EN_addlink(ph, "12", EN_PIPE, "12", "13");
error = EN_addlink(ph, (char *)"12", EN_PIPE, (char *)"12", (char *)"13");
BOOST_REQUIRE(error == 0);
error = EN_addlink(ph, "21", EN_PIPE, "21", "22");
error = EN_addlink(ph, (char *)"21", EN_PIPE, (char *)"21", (char *)"22");
BOOST_REQUIRE(error == 0);
error = EN_addlink(ph, "22", EN_PIPE, "22", "23");
error = EN_addlink(ph, (char *)"22", EN_PIPE, (char *)"22", (char *)"23");
BOOST_REQUIRE(error == 0);
error = EN_addlink(ph, "31", EN_PIPE, "31", "32");
error = EN_addlink(ph, (char *)"31", EN_PIPE, (char *)"31", (char *)"32");
BOOST_REQUIRE(error == 0);
error = EN_addlink(ph, "110", EN_PIPE, "2", "12");
error = EN_addlink(ph, (char *)"110", EN_PIPE, (char *)"2", (char *)"12");
BOOST_REQUIRE(error == 0);
error = EN_addlink(ph, "111", EN_PIPE, "11", "21");
error = EN_addlink(ph, (char *)"111", EN_PIPE, (char *)"11", (char *)"21");
BOOST_REQUIRE(error == 0);
error = EN_addlink(ph, "112", EN_PIPE, "12", "22");
error = EN_addlink(ph, (char *)"112", EN_PIPE, (char *)"12", (char *)"22");
BOOST_REQUIRE(error == 0);
error = EN_addlink(ph, "113", EN_PIPE, "13", "23");
error = EN_addlink(ph, (char *)"113", EN_PIPE, (char *)"13", (char *)"23");
BOOST_REQUIRE(error == 0);
error = EN_addlink(ph, "121", EN_PIPE, "21", "31");
error = EN_addlink(ph, (char *)"121", EN_PIPE, (char *)"21", (char *)"31");
BOOST_REQUIRE(error == 0);
error = EN_addlink(ph, "122", EN_PIPE, "22", "32");
error = EN_addlink(ph, (char *)"122", EN_PIPE, (char *)"22", (char *)"32");
BOOST_REQUIRE(error == 0);
for (i = 0; i < 12; i++)
{
@@ -163,13 +163,13 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
BOOST_REQUIRE(error == 0);
}
error = EN_addlink(ph, "9", EN_PUMP, "9", "10");
error = EN_addlink(ph, (char *)"9", EN_PUMP, (char *)"9", (char *)"10");
BOOST_REQUIRE(error == 0);
error = EN_addcurve(ph, "1");
error = EN_addcurve(ph, (char *)"1");
BOOST_REQUIRE(error == 0);
error = EN_setcurvevalue(ph, 1, 1, 1500, 250);
BOOST_REQUIRE(error == 0);
error = EN_getlinkindex(ph, "9", &ind);
error = EN_getlinkindex(ph, (char *)"9", &ind);
BOOST_REQUIRE(error == 0);
error = EN_setheadcurveindex(ph, ind, 1);
BOOST_REQUIRE(error == 0);
@@ -179,9 +179,9 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
error = EN_settimeparam(ph, EN_PATTERNSTEP, 2*3600);
BOOST_REQUIRE(error == 0);
error = EN_getlinkindex(ph, "9", &Lindex);
error = EN_getlinkindex(ph, (char *)"9", &Lindex);
BOOST_REQUIRE(error == 0);
error = EN_getnodeindex(ph, "2", &Nindex);
error = EN_getnodeindex(ph, (char *)"2", &Nindex);
BOOST_REQUIRE(error == 0);
// Add controls