gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master cd59e52 5/6: Merged not-yet-fully-complete wor


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master cd59e52 5/6: Merged not-yet-fully-complete work on libraries
Date: Sun, 11 Sep 2016 13:46:57 +0000 (UTC)

branch: master
commit cd59e52e13990560f8476b34927c997093f9494b
Merge: 118de44 2d15a91
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    Merged not-yet-fully-complete work on libraries
    
    The work on fully integrating libraries in Gnuastro is on-going, but we
    needed to make this merge since in the previous commit on the master branch
    (118de44: Gnulib's new getprogname module adopted), we are no longer
    importing Gnulib's `progname' module and so it was not easy to switch
    branches while developing (the full bootstrapping would have to be
    re-done).
    
    The main work on the library branch was to do with the documentation and we
    have just started to also allow C++ usage of the libraries. While the
    library documentation is still in the early stages, it works and that
    branch doesn't have any compilation problems, so this merge doesn't cause
    any problems on master. But development on that branch will continue
    separately as before unless another major change like this Gnulib update
    has to be applied.
---
 configure.ac                            |    1 +
 doc/gnuastro.texi                       |   87 +++++++++++++++++-
 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                       |    6 +-
 tests/lib/{version.c => versionc.c}     |    0
 tests/lib/{version.c => versioncpp.cpp} |   19 +---
 26 files changed, 616 insertions(+), 228 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/doc/gnuastro.texi b/doc/gnuastro.texi
index f0a61c2..01c4848 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -194,6 +194,7 @@ sub-component to a title is present.
 * Image analysis::              Analyze images.
 * Modeling and fittings::       Make and fit models.
 * High-level calculations::     Physical calculations.
+* Libraries::                   Use Gnuastro in your own code.
 * Developing::                  The development environment.
 * GNU Astronomy Utilities list::  List and short summary of Gnuastro.
 * Other useful software::       Installing other useful software.
@@ -491,6 +492,10 @@ CosmicCalculator
 * Extending distance concepts to 3D::  Going to 3D (our real universe).
 * Invoking astcosmiccal::       How to run CosmicCalculator
 
+Libraries
+
+* How to link with the libraries::  Guide on linking with libraries
+
 Developing
 
 * Why C::                       Why Gnuastro is designed in C.
@@ -13609,7 +13614,7 @@ were of integer types.
 
 
 
address@hidden High-level calculations, Developing, Modeling and fittings, Top
address@hidden High-level calculations, Libraries, Modeling and fittings, Top
 @chapter High-level calculations
 
 After the reduction of raw data (for example with the utilities in
@@ -14021,7 +14026,85 @@ of options and how to effectively use them.
 
 
 
address@hidden Developing, GNU Astronomy Utilities list, High-level 
calculations, Top
address@hidden Libraries, Developing, High-level calculations, Top
address@hidden Libraries
+
+Each utility or program in Gnuastro (or any program in general) is actually
+a collection of functions that is compiled into one executable file which
+can communicate directly with the outside world (for example the shell, see
address@hidden interface}). A compiled collection of functions
address@hidden any connection to the outside world is a library. By
+defining your own connections to the outside world in your a separate
+program, you can call a library's functions and compile them all together
+into a new program or utility. This way you can use Gnuastro at a
+lower-level, using the same building blocks (library functions) that
+Gnuastro's utilities benefit from in your own programs.
+
+
+
+
+
address@hidden
+* How to link with the libraries::  Guide on linking with libraries
address@hidden menu
+
address@hidden How to link with the libraries,  , Libraries, Libraries
address@hidden How to link with the libraries
+
+All Gnuastro library functions are compiled into one file depending on how
+you would like to link to the libraries: @file{libgnuastro.a} and
address@hidden Both contain all the functions that are discussed in
+this chapter. They are both installed in the @file{prefix/lib} directory
+(see @ref{Installation directory} for @file{prefix}).
+
address@hidden Static library
address@hidden Dynamic library
address@hidden Library, static
address@hidden Library, dynamic
+The first compiled code (with a @file{.a} suffix) is a static library which
+actually gets included into your program's executable file when you link to
+it. Since it is integrated into your program's code, it can be very
+efficient and if you uninstall Gnuastro or try to run it on a system that
+doesn't have Gnuastro, your program will still run. The second (with a
address@hidden suffix) is known as a dynamic library, the code from dynamic
+libraries will not be included in your executable file, each time your
+program is run, it will find the library and take the code from there. The
+main advantage of dynamic libraries is that when the library is updated,
+your program will use the updated library without the need to recompile
+your program. If you do static linking, you will have to recompile your
+program to benefit from the updated library. There are more factors to
+consider, these might be some of the more important ones but this is
+certainly not a thorough comparison.
+
+The compiled library files described above are not enough for actually
+using the libraries. Before linking, the compiler also needs to know the
+general description of the functions which you will be linking to: what
+type of input arguments each function needs and what type of output it
+produces. In C, these description files are known as a `header'
+(conventionally having a @file{.h} suffix). Unlike the compiled library
+code which was only one file, there are commonly many headers, classified
+by context (with similar functions described in one header file). In the
+case of Gnuastro, all the headers are installed in
address@hidden/include/gnuastro/} (see @ref{Installation directory}). Another
+major difference is that headers are human-readable: you can open them in a
+text editor and actually read them.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
address@hidden Developing, GNU Astronomy Utilities list, Libraries, Top
 @chapter Developing
 
 The basic idea of GNU Astronomy Utilities is for an interested
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 3a1db59..0cb6432 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)
 
 
 
@@ -78,24 +87,6 @@ pthread_barrier_destroy(pthread_barrier_t *b);
 
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 /*****************************************************************/
 /****************      gnuastro functions       ******************/
 /*****************************************************************/
@@ -107,4 +98,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 82e317c..ce77fe0 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -47,8 +47,10 @@ export hasghostscript=$(MAYBE_HASGHOSTSCRIPT);
 
 # Compilations that are to be done with `make check'.
 LDADD = -lgnuastro
-check_PROGRAMS = version
-version_SOURCES = lib/version.c
+CPPFLAGS = -I$(top_srcdir)/lib
+check_PROGRAMS = versionc versioncpp
+versionc_SOURCES = lib/versionc.c
+versioncpp_SOURCES = lib/versioncpp.cpp
 
 
 
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;
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]