Skip to content

Instantly share code, notes, and snippets.

@schwehr
Created February 19, 2014 17:29
Show Gist options
  • Save schwehr/9096958 to your computer and use it in GitHub Desktop.
Save schwehr/9096958 to your computer and use it in GitHub Desktop.
What it takes to make a parameter const for a function. You must edit (at a minimum) both the function prototype and function definition. Here, I am making the verbose argument const.
svn diff mb_define.h mb_defaults.c
Index: mb_define.h
===================================================================
--- mb_define.h (revision 2165)
+++ mb_define.h (working copy)
@@ -315,7 +315,7 @@
#define MB_PROJECTION_PROJECTED 1
/* MBIO core function prototypes */
-int mb_defaults(int verbose, int *format, int *pings,
+int mb_defaults(const int verbose, int *format, int *pings,
int *lonflip, double bounds[4],
int *btime_i, int *etime_i,
double *speedmin, double *timegap);
Index: mb_defaults.c
===================================================================
--- mb_defaults.c (revision 2165)
+++ mb_defaults.c (working copy)
@@ -120,7 +120,7 @@
static char rcs_id[]="$Id$";
/*--------------------------------------------------------------------*/
-int mb_defaults(int verbose, int *format, int *pings,
+int mb_defaults(const int verbose, int *format, int *pings,
int *lonflip, double bounds[4],
int *btime_i, int *etime_i,
double *speedmin, double *timegap)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment