Skip to content

Commit

Permalink
ISO c++ does not allow assigning string literals
Browse files Browse the repository at this point in the history
to non-cost char pointers.
Fix: use const char* instead
  • Loading branch information
peter-urban committed Nov 11, 2024
1 parent 8b141e5 commit 3271692
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions gsw_check_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ typedef struct gsw_error_info {
refval;
} gsw_error_info;

void report(char *funcname, char *varname, gsw_error_info *errs);
void check_accuracy(char *funcname, double accuracy, char *varname,
void report(const char *funcname, const char *varname, gsw_error_info *errs);
void check_accuracy(const char *funcname, double accuracy, const char *varname,
int count, double *calcval, double *refval);
void section_title(char *title);
void section_title(const char *title);

int debug=0, check_count, gsw_error_flag=0;
double c[cast_m*cast_n];
Expand Down Expand Up @@ -155,7 +155,7 @@ main(int argc, char **argv)
check_count = 1;
section_title("Practical Salinity, PSS-78");

test_func(c_from_sp, (sp[i],t[i],p[i]), c,c_from_sp);
test_func(c_from_sp, (sp[i],t[i],p[i]), c, c_from_sp);
test_func(sp_from_c, (c[i],t[i],p[i]), value,sp_from_c);
test_func(sp_from_sk, (sk[i]), value,sp_from_sk);
test_func(sp_salinometer, (rt[i], t[i]), value,sp_salinometer);
Expand Down Expand Up @@ -633,20 +633,20 @@ main(int argc, char **argv)
}

void
section_title(char *title)
section_title(const char *title)
{
printf("\n------------------------------------------------"
"----------------------------\n%s\n\n",title);
}

void
report(char *funcname, char *varname, gsw_error_info *errs)
report(const char *funcname, const char *varname, gsw_error_info *errs)
{
int msglen = strlen(funcname)+((varname==NULL)?0:strlen(varname)),
k, ndots;
char message[81], *dots, infoflg[8];
char message[81], infoflg[8];

dots ="...............................................................";
const char* dots ="...............................................................";
strcpy(message, funcname);
if (strcmp(funcname, varname)) {
msglen += 5;
Expand Down Expand Up @@ -682,8 +682,8 @@ report(char *funcname, char *varname, gsw_error_info *errs)
}

void
check_accuracy(char *funcname, double accuracy, char *varname, int count,
double *calcval, double *refval)
check_accuracy(const char *funcname, double accuracy,const char *varname,
int count, double *calcval, double *refval)
{
int i;
double diff;
Expand Down
6 changes: 3 additions & 3 deletions gsw_saar_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
** Extracted from ../../gsw_matlab_v3_06_16/library/gsw_data_v3_0.mat
*/
static int gsw_nx = 91, gsw_ny = 45, gsw_nz = 45;
static char *gsw_version_date = "15th_May_2011";
static char *gsw_version_number = "3.06.16";
static const char *gsw_version_date = "15th_May_2011";
static const char *gsw_version_number = "3.06.16";

void gsw_get_version(char **version_date, char **version_number)
void gsw_get_version(const char **version_date, const char **version_number)
{
*version_date = gsw_version_date;
*version_number = gsw_version_number;
Expand Down

0 comments on commit 3271692

Please sign in to comment.