[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master cc89d3c 2/6: Libraries are usable in C++
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master cc89d3c 2/6: Libraries are usable in C++ |
Date: |
Sun, 11 Sep 2016 13:46:56 +0000 (UTC) |
branch: master
commit cc89d3c33cc212e5c38405cbc1eea429c0db5ebb
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
Libraries are usable in C++
As part of tasks #13765 and #13786, the library header files can now be
included in C++ programs. The guidelines suggested by GNU Libtool (in the
"Writing C header files" section of the "Library tips") were followed. A
small test program (to print the version of Gnuastro) was written in C++
and is now also compiled along with the rest of the tests.
While going through the header files some cases where the line-lengths were
too long were also corrected.
---
configure.ac | 1 +
lib/gnuastro/arraymanip.h | 30 +++++-
lib/gnuastro/box.h | 30 +++++-
lib/gnuastro/checkset.h | 55 ++++++-----
lib/gnuastro/commonargs.h | 4 +-
lib/gnuastro/commonparams.h | 37 ++++----
lib/gnuastro/configfiles.h | 28 +++++-
lib/gnuastro/fits.h | 26 +++++-
lib/gnuastro/fixedstringmacros.h | 9 +-
lib/gnuastro/gnuastro.h | 28 +++++-
lib/gnuastro/linkedlist.h | 151 +++++++++----------------------
lib/gnuastro/mesh.h | 26 +++++-
lib/gnuastro/mode.h | 30 +++++-
lib/gnuastro/neighbors.h | 26 +++++-
lib/gnuastro/polygon.h | 27 +++++-
lib/gnuastro/qsort.h | 31 ++++++-
lib/gnuastro/spatialconvolve.h | 33 +++++--
lib/gnuastro/statistics.h | 31 ++++++-
lib/gnuastro/threads.h | 49 +++++-----
lib/gnuastro/timing.h | 29 +++++-
lib/gnuastro/txtarray.h | 22 ++++-
lib/gnuastro/wcs.h | 29 +++++-
tests/Makefile.am | 34 +++----
tests/lib/{version.c => versionc.c} | 0
tests/lib/{version.c => versioncpp.cpp} | 19 +---
25 files changed, 544 insertions(+), 241 deletions(-)
diff --git a/configure.ac b/configure.ac
index c3d54f5..7ff9310 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,6 +58,7 @@ anywarnings=no
# Checks for programs.
: ${CFLAGS=""}
AC_PROG_CC
+AC_PROG_CXX
gl_EARLY
AM_PROG_AR
LT_INIT
diff --git a/lib/gnuastro/arraymanip.h b/lib/gnuastro/arraymanip.h
index aa33cfc..79b747a 100644
--- a/lib/gnuastro/arraymanip.h
+++ b/lib/gnuastro/arraymanip.h
@@ -23,6 +23,30 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_ARRAYMANIP_H__
#define __GAL_ARRAYMANIP_H__
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
+
+
+
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
+
+
+
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
+
+
+
void
gal_arraymanip_uchar_init_on_region(unsigned char *in, const unsigned char v,
size_t start, size_t s0, size_t s1,
@@ -126,4 +150,8 @@ gal_arraymanip_dlog10_array(double *in1, size_t size);
void
gal_arraymanip_dabs_array(double *in1, size_t size);
-#endif
+
+
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_ARRAYMANIP_H__ */
diff --git a/lib/gnuastro/box.h b/lib/gnuastro/box.h
index e702979..5ee522a 100644
--- a/lib/gnuastro/box.h
+++ b/lib/gnuastro/box.h
@@ -23,6 +23,30 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_BOX_H__
#define __GAL_BOX_H__
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
+
+
+
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
+
+
+
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
+
+
+
/* IMPORTANT NOTE:
All the axises are based on the FITS standard, NOT C.
*/
@@ -38,4 +62,8 @@ int
gal_box_overlap(long *naxes, long *fpixel_i, long *lpixel_i,
long *fpixel_o, long *lpixel_o);
-#endif
+
+
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_BOX_H__ */
diff --git a/lib/gnuastro/checkset.h b/lib/gnuastro/checkset.h
index 51f2ab0..719be01 100644
--- a/lib/gnuastro/checkset.h
+++ b/lib/gnuastro/checkset.h
@@ -23,10 +23,32 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_CHECKSET_H__
#define __GAL_CHECKSET_H__
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
#include <math.h>
#include <fitsio.h>
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
+
+
+
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
+
+
+
+
/**************************************************************/
/********* Macros **************/
/**************************************************************/
@@ -72,19 +94,6 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
-
-
-
-
-
-
-
-
-
-
-
-
-
/****************************************************************
************ Check and convert strings *****************
****************************************************************/
@@ -93,8 +102,6 @@ strisdouble(char *string, double *out);
-
-
/**************************************************************/
/********* Read arguments and check their values **************/
/**************************************************************/
@@ -170,8 +177,6 @@ gal_checkset_any_double(char *optarg, double *var, char
*lo, char so,
-
-
/**************************************************************/
/********** Check fixed strings ************/
/**************************************************************/
@@ -181,12 +186,6 @@ gal_checkset_known_types(char *optarg, int *bitpix, char
*filename,
-
-
-
-
-
-
/**************************************************************/
/********** My String functions: ************/
/**************************************************************/
@@ -205,10 +204,6 @@ gal_checkset_allocate_copy_set(char *arg, char **copy, int
*set);
-
-
-
-
/**************************************************************/
/********** Set file names and check if they exist ************/
/**************************************************************/
@@ -238,4 +233,8 @@ gal_checkset_not_dir_part(char *input);
void
gal_checkset_check_dir_write_add_slash(char **dirname);
-#endif
+
+
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_CHECKSET_H__ */
diff --git a/lib/gnuastro/commonargs.h b/lib/gnuastro/commonargs.h
index 8e5fe5d..8bc678d 100644
--- a/lib/gnuastro/commonargs.h
+++ b/lib/gnuastro/commonargs.h
@@ -290,4 +290,6 @@ static struct argp commonargp = {gal_commonargs_options,
gal_checkset_commonargs_cparse_opt,
NULL, NULL, NULL, NULL, NULL};
-#endif
+
+
+#endif /* __GAL_COMMONARGS_H__ */
diff --git a/lib/gnuastro/commonparams.h b/lib/gnuastro/commonparams.h
index 4dc41f7..f5b6259 100644
--- a/lib/gnuastro/commonparams.h
+++ b/lib/gnuastro/commonparams.h
@@ -24,36 +24,37 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#define __GAL_COMMONPARAMS_H__
+
/* The structure keeping all the common parameters in gnuastro. This
could be part of commonargs.h, but since main.h in all those
programs will need this structure, there will be problems about the
unused `commonargp` structure.*/
struct gal_commonparams
{
- char *spack; /* Subpackage name. */
+ char *spack; /* Subpackage name. */
/* Input/Output: */
- char *output; /* Directory containg output. */
- char *hdu; /* Image extension. */
- int dontdelete; /* ==1: Don't delete existing. */
- int removedirinfo; /* ==1: Remove directory information. */
+ char *output; /* Directory containg output. */
+ char *hdu; /* Image extension. */
+ int dontdelete; /* ==1: Don't delete existing. */
+ int removedirinfo; /* ==1: Remove directory information. */
/* Operating modes: */
- int verb; /* ==1: report steps. ==0 don't. */
- int printparams; /* Only print the used values. */
- int setdirconf; /* ==1: Set the current directory default values.*/
- int setusrconf; /* ==1: Set the user default values. */
- size_t numthreads; /* Number of threads to use. */
- int onlydirconf; /* Only check current directory conf. file. */
- char *onlyversion; /* The string of the requested version. */
- int nolog; /* ==1: do not make a log file. */
+ int verb; /* ==1: report steps. ==0 don't. */
+ int printparams; /* Only print the used values. */
+ int setdirconf; /* ==1: Set the current directory config. */
+ int setusrconf; /* ==1: Set the user default values. */
+ size_t numthreads; /* Number of threads to use. */
+ int onlydirconf; /* Only check current directory conf. file. */
+ char *onlyversion; /* The string of the requested version. */
+ int nolog; /* ==1: do not make a log file. */
/* Check: */
- int numthreadsset; /* If the number of threads are set. */
- int onlyversionset; /* If the only version option is set. */
- int hduset; /* If the input image extension is set. */
- int outputset; /* If the output is set. */
- int nologset; /* If nolog is set. */
+ int numthreadsset; /* If the number of threads are set. */
+ int onlyversionset; /* If the only version option is set. */
+ int hduset; /* If the input image extension is set. */
+ int outputset; /* If the output is set. */
+ int nologset; /* If nolog is set. */
};
#endif
diff --git a/lib/gnuastro/configfiles.h b/lib/gnuastro/configfiles.h
index 5c67765..3663486 100644
--- a/lib/gnuastro/configfiles.h
+++ b/lib/gnuastro/configfiles.h
@@ -23,6 +23,28 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_CONFIGFILES_H__
#define __GAL_CONFIGFILES_H__
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
+
+
+
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
+
+
+
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
+
/**************************************************************/
@@ -228,4 +250,8 @@ gal_configfiles_write_local_config_stop(char *indir, char
*filename,
void
gal_configfiles_print_type(FILE *fp, int bitpix);
-#endif
+
+
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_CONFIGFILES_H__ */
diff --git a/lib/gnuastro/fits.h b/lib/gnuastro/fits.h
index 4a81360..f867861 100644
--- a/lib/gnuastro/fits.h
+++ b/lib/gnuastro/fits.h
@@ -23,11 +23,12 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_FITS_H__
#define __GAL_FITS_H__
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
#include <math.h>
#include <float.h>
#include <stdint.h>
#include <limits.h>
-
#include <fitsio.h>
#include <wcslib/wcs.h>
#include <wcslib/wcshdr.h>
@@ -36,6 +37,23 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
+
+
+
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
+
/* Order is based on the CFITSIO manual. Note that for the unsigned types
@@ -280,4 +298,8 @@ void
gal_fits_prep_float_kernel(char *inputname, char *inhdu, float **kernel,
size_t *ins0, size_t *ins1);
-#endif
+
+
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_FITS_H__ */
diff --git a/lib/gnuastro/fixedstringmacros.h b/lib/gnuastro/fixedstringmacros.h
index b46919b..1979cdf 100644
--- a/lib/gnuastro/fixedstringmacros.h
+++ b/lib/gnuastro/fixedstringmacros.h
@@ -20,8 +20,9 @@ General Public License for more details.
You should have received a copy of the GNU General Public License
along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
**********************************************************************/
-#ifndef __GAL_COPYRIGHT_H__
-#define __GAL_COPYRIGHT_H__
+#ifndef __GAL_FIXEDSTRINGMACROS_H__
+#define __GAL_FIXEDSTRINGMACROS_H__
+
#define GAL_STRINGS_SHORT_COPYRIGHT \
@@ -90,4 +91,6 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
" You can check all the input values with the `--printparams' " \
"(-P) option."
-#endif
+
+
+#endif /* __GAL_FIXEDSTRINGMACROS_H__ */
diff --git a/lib/gnuastro/gnuastro.h b/lib/gnuastro/gnuastro.h
index 16426ac..a9c56b1 100644
--- a/lib/gnuastro/gnuastro.h
+++ b/lib/gnuastro/gnuastro.h
@@ -22,10 +22,36 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_GNUASTRO_H__
#define __GAL_GNUASTRO_H__
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
+
+
+
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
+
+
+
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
+
/* Report the Gnuastro version number. */
char *
gal_gnuastro_version(void);
-#endif
+
+
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_GNUASTRO_H__ */
diff --git a/lib/gnuastro/linkedlist.h b/lib/gnuastro/linkedlist.h
index daac34c..700332f 100644
--- a/lib/gnuastro/linkedlist.h
+++ b/lib/gnuastro/linkedlist.h
@@ -23,6 +23,28 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_SLL_H__
#define __GAL_SLL_H__
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
+
+
+
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
+
+
+
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
+
/******************* Two doubles (for coordinates) */
@@ -53,23 +75,6 @@ gal_linkedlist_free_tdll(struct gal_linkedlist_tdll *list);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/******************* float: */
struct gal_linkedlist_fll
{
@@ -78,13 +83,16 @@ struct gal_linkedlist_fll
};
void
-gal_linkedlist_print_fll_array(struct gal_linkedlist_fll **afll, size_t num);
+gal_linkedlist_print_fll_array(struct gal_linkedlist_fll **afll,
+ size_t num);
void
-gal_linkedlist_add_to_fll(struct gal_linkedlist_fll **list, float value);
+gal_linkedlist_add_to_fll(struct gal_linkedlist_fll **list,
+ float value);
void
-gal_linkedlist_pop_from_fll(struct gal_linkedlist_fll **list, float *value);
+gal_linkedlist_pop_from_fll(struct gal_linkedlist_fll **list,
+ float *value);
size_t
gal_linkedlist_num_in_fll(struct gal_linkedlist_fll *list);
@@ -97,24 +105,8 @@ void
gal_linkedlist_free_fll(struct gal_linkedlist_fll *list);
void
-gal_linkedlist_free_fll_array(struct gal_linkedlist_fll **afll, size_t num);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+gal_linkedlist_free_fll_array(struct gal_linkedlist_fll **afll,
+ size_t num);
@@ -126,10 +118,12 @@ struct gal_linkedlist_stll
};
void
-gal_linkedlist_add_to_stll(struct gal_linkedlist_stll **list, char *value);
+gal_linkedlist_add_to_stll(struct gal_linkedlist_stll **list,
+ char *value);
void
-gal_linkedlist_pop_from_stll(struct gal_linkedlist_stll **list, char **value);
+gal_linkedlist_pop_from_stll(struct gal_linkedlist_stll **list,
+ char **value);
void
gal_linkedlist_reverse_stll(struct gal_linkedlist_stll **list);
@@ -142,20 +136,6 @@ gal_linkedlist_num_in_stll(struct gal_linkedlist_stll
*list);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/******************* size_t: */
struct gal_linkedlist_sll
{
@@ -164,10 +144,12 @@ struct gal_linkedlist_sll
};
void
-gal_linkedlist_add_to_sll(struct gal_linkedlist_sll **list, size_t value);
+gal_linkedlist_add_to_sll(struct gal_linkedlist_sll **list,
+ size_t value);
void
-gal_linkedlist_pop_from_sll(struct gal_linkedlist_sll **list, size_t *value);
+gal_linkedlist_pop_from_sll(struct gal_linkedlist_sll **list,
+ size_t *value);
size_t
gal_linkedlist_num_in_sll(struct gal_linkedlist_sll *list);
@@ -184,23 +166,6 @@ gal_linkedlist_free_sll(struct gal_linkedlist_sll *list);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/******************* Two way size_t: */
struct gal_linkedlist_tsll
{
@@ -219,23 +184,6 @@ gal_linkedlist_pop_from_tsll_start(struct
gal_linkedlist_tsll **first,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/******************* Ordered size_t: */
struct gal_linkedlist_osll
{
@@ -258,23 +206,6 @@ gal_linkedlist_osll_into_sll(struct gal_linkedlist_osll
*in,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/******************* Two way ordered size_t: */
struct gal_linkedlist_tosll
{
@@ -309,4 +240,8 @@ gal_linkedlist_tosll_into_sll(struct gal_linkedlist_tosll
*in,
void
gal_linkedlist_tosll_free(struct gal_linkedlist_tosll *largest);
-#endif
+
+
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_LINKEDLIST_H__ */
diff --git a/lib/gnuastro/mesh.h b/lib/gnuastro/mesh.h
index c533d39..d8b4c49 100644
--- a/lib/gnuastro/mesh.h
+++ b/lib/gnuastro/mesh.h
@@ -23,14 +23,30 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_MESH_H__
#define __GAL_MESH_H__
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
+#include <wcslib/wcs.h>
+#include <gnuastro/threads.h>
-#include <wcslib/wcs.h>
-#include <gnuastro/threads.h>
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
+
/* Operations to do on each mesh. If input parameters are needed (for
@@ -197,4 +213,8 @@ gal_mesh_spatial_convolve_on_mesh(struct gal_mesh_params
*mp, float **conv);
void
gal_mesh_change_to_full_convolution(struct gal_mesh_params *mp, float *conv);
-#endif
+
+
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_MESH_H__ */
diff --git a/lib/gnuastro/mode.h b/lib/gnuastro/mode.h
index 19372ea..1c38afa 100644
--- a/lib/gnuastro/mode.h
+++ b/lib/gnuastro/mode.h
@@ -23,6 +23,30 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_MODE_H__
#define __GAL_MODE_H__
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
+
+
+
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
+
+
+
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
+
+
+
#define GAL_MODE_LOW_QUANTILE 0.01f
#define GAL_MODE_HIGH_QUANTILE 0.51f
@@ -64,4 +88,8 @@ void
gal_mode_index_in_sorted(float *sorted, size_t size, float errorstdm,
size_t *modeindex, float *modesym);
-#endif
+
+
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_MODE_H__ */
diff --git a/lib/gnuastro/neighbors.h b/lib/gnuastro/neighbors.h
index b4dd732..6104ac1 100644
--- a/lib/gnuastro/neighbors.h
+++ b/lib/gnuastro/neighbors.h
@@ -23,6 +23,28 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_NEIGHBORS_H__
#define __GAL_NEIGHBORS_H__
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
+
+
+
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
+
+
+
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
+
/* These macros can be put any where you want to know the neighbors of
an index, the important values that have to be declared and defined
@@ -125,4 +147,6 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
} \
}
-#endif
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_NEIGHBORS_H__ */
diff --git a/lib/gnuastro/polygon.h b/lib/gnuastro/polygon.h
index 99a03a6..c9960c3 100644
--- a/lib/gnuastro/polygon.h
+++ b/lib/gnuastro/polygon.h
@@ -23,9 +23,29 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_POLYGON_H__
#define __GAL_POLYGON_H__
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
+
+
+
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
+
+
#define GAL_POLYGON_MAX_CORNERS 50
#define GAL_POLYGON_ROUND_ERR 1e-5
@@ -126,4 +146,9 @@ gal_polygon_clip(double *s, size_t n, double *c, size_t m,
#define GAL_POLYGON_MIN_OF_TWO(A, B) ((A)<(B)+GAL_POLYGON_ROUND_ERR ? (A) :
(B))
#define GAL_POLYGON_MAX_OF_TWO(A, B) ((A)>(B)-GAL_POLYGON_ROUND_ERR ? (A) :
(B))
-#endif
+
+
+
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_POLYGON_H__ */
diff --git a/lib/gnuastro/qsort.h b/lib/gnuastro/qsort.h
index db17220..2d71b43 100644
--- a/lib/gnuastro/qsort.h
+++ b/lib/gnuastro/qsort.h
@@ -23,6 +23,31 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_QSORT_H__
#define __GAL_QSORT_H__
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
+
+
+
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
+
+
+
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
+
+
+
+
/* Pointer used to sort the indexs of an array based on their flux
(value in this array). */
extern float *gal_qsort_index_arr;
@@ -48,4 +73,8 @@ gal_qsort_double_decreasing(const void * a, const void * b);
int
gal_qsort_double_increasing(const void * a, const void * b);
-#endif
+
+
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_QSORT_H__ */
diff --git a/lib/gnuastro/spatialconvolve.h b/lib/gnuastro/spatialconvolve.h
index 9017b4f..c249b5c 100644
--- a/lib/gnuastro/spatialconvolve.h
+++ b/lib/gnuastro/spatialconvolve.h
@@ -23,14 +23,28 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_SPATIALCONVOLVE_H__
#define __GAL_SPATIALCONVOLVE_H__
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
+#include <gnuastro/threads.h> /* For pthread_barrier_t: */
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
-/* For pthread_barrier_t: */
-#include <gnuastro/threads.h>
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
@@ -59,13 +73,12 @@ struct gal_spatialconvolve_params
-
-
/* Functions: */
void
-gal_spatialconvolve_pparams(float *input, size_t is0, size_t is1, float
*kernel,
- size_t ks0, size_t ks1, size_t nt,
- int edgecorrection, float *out, size_t *indexs,
+gal_spatialconvolve_pparams(float *input, size_t is0, size_t is1,
+ float *kernel, size_t ks0, size_t ks1,
+ size_t nt, int edgecorrection, float *out,
+ size_t *indexs,
struct gal_spatialconvolve_params *scp);
void *
@@ -76,4 +89,8 @@ gal_spatialconvolve_convolve(float *input, size_t is0, size_t
is1,
float *kernel, size_t ks0, size_t ks1,
size_t nt, int edgecorrection, float **out);
-#endif
+
+
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_SPATIALCONVOLVE_H__ */
diff --git a/lib/gnuastro/statistics.h b/lib/gnuastro/statistics.h
index d4df04b..8bdee9b 100644
--- a/lib/gnuastro/statistics.h
+++ b/lib/gnuastro/statistics.h
@@ -23,7 +23,31 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_STATISTICS_H__
#define __GAL_STATISTICS_H__
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
+
+
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
+
+
+
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
+
+
+
+/* Maximum number of tests for sigma-clipping convergence */
#define GAL_STATISTICS_MAX_SIG_CLIP_CONVERGE 50
@@ -240,4 +264,9 @@ gal_statistics_sigma_clip_certain_num(float *array, int
o1_n0, size_t num_elem,
/****************************************************************/
void
gal_statistics_remove_outliers_flat_cdf(float *sorted, size_t *outsize);
-#endif
+
+
+
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_STATISTICS_H__ */
diff --git a/lib/gnuastro/threads.h b/lib/gnuastro/threads.h
index d0b276b..80fffdd 100644
--- a/lib/gnuastro/threads.h
+++ b/lib/gnuastro/threads.h
@@ -23,24 +23,33 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_THREADS_H__
#define __GAL_THREADS_H__
-
-
-
-
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
#include <pthread.h>
-
-
-#define GAL_THREADS_NON_THRD_INDEX (size_t)(-1)
-
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
+/* Constant to use for non-existant index */
+#define GAL_THREADS_NON_THRD_INDEX (size_t)(-1)
@@ -72,24 +81,6 @@ pthread_barrier_wait(pthread_barrier_t *b);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/*****************************************************************/
/**************** gnuastro functions ******************/
/*****************************************************************/
@@ -101,4 +92,8 @@ void
gal_threads_attr_barrier_init(pthread_attr_t *attr, pthread_barrier_t *b,
size_t numthreads);
-#endif
+
+
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_THREADS_H__ */
diff --git a/lib/gnuastro/timing.h b/lib/gnuastro/timing.h
index 58c9474..e19f3e5 100644
--- a/lib/gnuastro/timing.h
+++ b/lib/gnuastro/timing.h
@@ -23,9 +23,32 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_TIMING_H__
#define __GAL_TIMING_H__
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
#include <time.h>
#include <sys/time.h>
+
+
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
+
+
+
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
+
+
+
#define GAL_TIMING_VERB_MSG_LENGTH_V 45
#define GAL_TIMING_VERB_MSG_LENGTH_T "45"
#define GAL_TIMING_VERB_MSG_LENGTHS_2_V 65
@@ -37,4 +60,8 @@ gal_timing_time_based_rng_seed();
void
gal_timing_report(struct timeval *t1, char *jobname, size_t level);
-#endif
+
+
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_TIMING_H__ */
diff --git a/lib/gnuastro/txtarray.h b/lib/gnuastro/txtarray.h
index 6c65281..c394aa5 100644
--- a/lib/gnuastro/txtarray.h
+++ b/lib/gnuastro/txtarray.h
@@ -23,10 +23,27 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_TXTARRAY_H__
#define __GAL_TXTARRAY_H__
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
#include <float.h>
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
+
+
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
@@ -58,4 +75,7 @@ gal_txtarray_array_to_txt(double *array, size_t s0, size_t
s1, char *comments,
int *int_cols, int *accu_cols, int *space, int *prec,
char forg, const char *filename);
-#endif
+
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_TXTARRAY_H__ */
diff --git a/lib/gnuastro/wcs.h b/lib/gnuastro/wcs.h
index 2cb80a6..07be4ca 100644
--- a/lib/gnuastro/wcs.h
+++ b/lib/gnuastro/wcs.h
@@ -23,8 +23,31 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#ifndef __GAL_WCS_H__
#define __GAL_WCS_H__
+/* Include other headers if necessary here. Note that other header files
+ must be included before the C++ preparations below */
#include <wcslib/wcs.h>
+
+
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS /* empty */
+# define __END_C_DECLS /* empty */
+#endif
+/* End of C++ preparations */
+
+
+
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS /* From C++ preparations */
+
+
+
void
gal_wcs_xy_array_to_radec(struct wcsprm *wcs, double *xy, double *radec,
size_t number, size_t width);
@@ -36,4 +59,8 @@ gal_wcs_radec_array_to_xy(struct wcsprm *wcs, double *radec,
double *xy,
double
gal_wcs_pixel_area_arcsec2(struct wcsprm *wcs);
-#endif
+
+
+__END_C_DECLS /* From C++ preparations */
+
+#endif /* __GAL_WCS_H__ */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fb5943d..3512b01 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -47,28 +47,28 @@ export hasghostscript=$(MAYBE_HASGHOSTSCRIPT);
# Compilations that are to be done with `make check'.
LDADD = -lgnuastro
-check_PROGRAMS = version
-version_SOURCES = lib/version.c
+check_PROGRAMS = versionc versioncpp
+versionc_SOURCES = lib/versionc.c
+versioncpp_SOURCES = lib/versioncpp.cpp
# The actual test scripts that are run:
-TESTS = prepconf.sh mkprof/mosaic1.sh mkprof/mosaic2.sh mkprof/mosaic3.sh \
- mkprof/mosaic4.sh mkprof/radeccat.sh imgcrop/imgcat.sh imgcrop/wcscat.sh \
- imgcrop/xcyc.sh imgcrop/xcycnoblank.sh imgcrop/section.sh \
- imgcrop/radec.sh imgcrop/imgpolygon.sh imgcrop/imgoutpolygon.sh \
- imgcrop/wcspolygon.sh convertt/fitstotxt.sh convertt/fitstojpeg.sh \
- convertt/blankch.sh convertt/jpegtotxt.sh convertt/fitstojpegcmyk.sh \
- convertt/jpegtofits.sh convertt/fitstopdf.sh convolve/spatial.sh \
- convolve/frequency.sh imgwarp/imgwarp_scale.sh imgwarp/homographic.sh \
- mknoise/addnoise.sh mkprof/ellipticalmasks.sh mkprof/inputascanvas.sh \
- header/write.sh header/print.sh header/update.sh header/delete.sh \
- imgstat/basicstats.sh subtractsky/subtractsky.sh \
- noisechisel/noisechisel.sh mkcatalog/simple.sh mkcatalog/aperturephot.sh \
- arithmetic/snimage.sh arithmetic/onlynumbers.sh arithmetic/where.sh \
- cosmiccal/simpletest.sh table/asciitobinary.sh table/binarytoascii.sh \
- $(check_PROGRAMS)
+TESTS = $(check_PROGRAMS) prepconf.sh mkprof/mosaic1.sh mkprof/mosaic2.sh \
+ mkprof/mosaic3.sh mkprof/mosaic4.sh mkprof/radeccat.sh imgcrop/imgcat.sh \
+ imgcrop/wcscat.sh imgcrop/xcyc.sh imgcrop/xcycnoblank.sh \
+ imgcrop/section.sh imgcrop/radec.sh imgcrop/imgpolygon.sh \
+ imgcrop/imgoutpolygon.sh imgcrop/wcspolygon.sh convertt/fitstotxt.sh \
+ convertt/fitstojpeg.sh convertt/blankch.sh convertt/jpegtotxt.sh \
+ convertt/fitstojpegcmyk.sh convertt/jpegtofits.sh convertt/fitstopdf.sh \
+ convolve/spatial.sh convolve/frequency.sh imgwarp/imgwarp_scale.sh \
+ imgwarp/homographic.sh mknoise/addnoise.sh mkprof/ellipticalmasks.sh \
+ mkprof/inputascanvas.sh header/write.sh header/print.sh header/update.sh \
+ header/delete.sh imgstat/basicstats.sh subtractsky/subtractsky.sh \
+ noisechisel/noisechisel.sh mkcatalog/simple.sh mkcatalog/aperturephot.sh \
+ arithmetic/snimage.sh arithmetic/onlynumbers.sh arithmetic/where.sh \
+ cosmiccal/simpletest.sh table/asciitobinary.sh table/binarytoascii.sh
diff --git a/tests/lib/version.c b/tests/lib/versionc.c
similarity index 100%
copy from tests/lib/version.c
copy to tests/lib/versionc.c
diff --git a/tests/lib/version.c b/tests/lib/versioncpp.cpp
similarity index 76%
rename from tests/lib/version.c
rename to tests/lib/versioncpp.cpp
index 2044823..14ff2a3 100644
--- a/tests/lib/version.c
+++ b/tests/lib/versioncpp.cpp
@@ -1,5 +1,5 @@
/*********************************************************************
-A test program to get and use the version number of Gnuastro within C.
+A test program to get and use the version number of Gnuastro within C++.
Original author:
Mohammad Akhlaghi <address@hidden>
@@ -20,26 +20,17 @@ You should have received a copy of the GNU General Public
License
along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
**********************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdlib>
+#include <iostream>
-#include "gnuastro/gnuastro.h"
+#include <gnuastro/gnuastro.h>
int
main(void)
{
- /* Pointer to the string version */
char *version=NULL;
-
- /* Fill in both with the version string. */
version=gal_gnuastro_version();
-
- /* Print the version. */
- printf("Gnuastro version is: %s\n", version);
-
- /* Free the allocated space for the version. */
+ std::cout << "Gnuastro version is: " << version << ".";
free(version);
-
- /* Cleanup and return */
return EXIT_SUCCESS;
}
- [gnuastro-commits] master updated (d5ca7d3 -> 25d2ec5), Mohammad Akhlaghi, 2016/09/11
- [gnuastro-commits] master 2d15a91 3/6: CPP include directories overwritten, Mohammad Akhlaghi, 2016/09/11
- [gnuastro-commits] master c9f04ca 1/6: Started the new Library chapter, with basic introductions, Mohammad Akhlaghi, 2016/09/11
- [gnuastro-commits] master 118de44 4/6: Gnulib's new getprogname module adopted, Mohammad Akhlaghi, 2016/09/11
- [gnuastro-commits] master 25d2ec5 6/6: bootstrapped/lib only included in libraries and utilities, Mohammad Akhlaghi, 2016/09/11
- [gnuastro-commits] master cc89d3c 2/6: Libraries are usable in C++,
Mohammad Akhlaghi <=
- [gnuastro-commits] master cd59e52 5/6: Merged not-yet-fully-complete work on libraries, Mohammad Akhlaghi, 2016/09/11