]> granicus.if.org Git - graphviz/commitdiff
lib/sparse: add guards, making headers safe to include from C++
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 25 Dec 2021 19:09:15 +0000 (11:09 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 4 Jan 2022 15:56:35 +0000 (07:56 -0800)
An upcoming change will convert cmd/mingle/minglemain.c to C++, which
transitively includes some of these headers.

Related to #2154.

12 files changed:
lib/sparse/BinaryHeap.h
lib/sparse/DotIO.h
lib/sparse/IntStack.h
lib/sparse/LinkedList.h
lib/sparse/QuadTree.h
lib/sparse/SparseMatrix.h
lib/sparse/clustering.h
lib/sparse/color_palette.h
lib/sparse/colorutil.h
lib/sparse/general.h
lib/sparse/mq.h
lib/sparse/vector.h

index 462043f45c1badfc17177398502c95da253f5f0b..d634aa87eba42daa8181d96fdbfefc0aa8a50e81 100644 (file)
 #include <sparse/IntStack.h>
 #include <stddef.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* binary heap code. 
    Caution: items inserted should be kept untouched, e.g., the value of the item should be kepted unchanged while the heap is still in use! 
    To change the valud of am item, use BinaryHeap_reset
@@ -70,3 +74,7 @@ size_t BinaryHeap_reset(BinaryHeap h, int id, void *item);/* reset value of an i
 void BinaryHeap_print(BinaryHeap h, void (*pnt)(void*));
 
 void BinaryHeap_sanity_check(BinaryHeap h);
+
+#ifdef __cplusplus
+}
+#endif
index fd20204a2699c07b25bba2d4a578cb71323b07d6..f14a74d05876af12b3f2cfe44dff2676e0914a57 100644 (file)
 #include <cgraph.h>
 #include <sparse/SparseMatrix.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 enum {COLOR_SCHEME_NONE, COLOR_SCHEME_PASTEL = 1, COLOR_SCHEME_BLUE_YELLOW, COLOR_SCHEME_WHITE_RED, COLOR_SCHEME_GREY_RED, COLOR_SCHEME_PRIMARY, COLOR_SCHEME_SEQUENTIAL_SINGLEHUE_RED, COLOR_SCHEME_ADAM, COLOR_SCHEME_ADAM_BLEND, COLOR_SCHEME_SEQUENTIAL_SINGLEHUE_RED_LIGHTER, COLOR_SCHEME_GREY};
 extern void initDotIO (Agraph_t *g);
 
@@ -31,3 +35,7 @@ void Dot_SetClusterColor(Agraph_t* g, float *rgb_r,  float *rgb_g,  float *rgb_b
 void attached_clustering(Agraph_t* g, int maxcluster, int clustering_scheme);
 
 int Import_dot_splines(Agraph_t* g, int *ne, char ***xsplines);
+
+#ifdef __cplusplus
+}
+#endif
index 03e1de2f741b20d740614fb352ee11ed1510f3a7..68a219d07d82fd17e08c616210df975ff707d646 100644 (file)
 
 #include <stddef.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* last in first out integer stack */
 struct IntStack_struct{
   size_t last; // position of the last element, If empty, last = SIZE_MAX
@@ -33,3 +37,7 @@ size_t IntStack_push(IntStack s, int i); // add an item and return the pos
 int IntStack_pop(IntStack s, int *flag);/* remove the last item. If none exist, flag = -1, and return -1. */
 
 void IntStack_print(IntStack s);
+
+#ifdef __cplusplus
+}
+#endif
index 488dff5a7554653dee17f9526a5cac67a351bbc1..0c098d9d0ccb149730c98852176e9f4ff941cb45 100644 (file)
 
 #pragma once
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct SingleLinkedList_struct* SingleLinkedList;
 
 struct SingleLinkedList_struct {
@@ -47,3 +51,7 @@ void* DoubleLinkedList_get_data(DoubleLinkedList l);
 DoubleLinkedList DoubleLinkedList_get_next(DoubleLinkedList l);
 
 void DoubleLinkedList_delete_element(DoubleLinkedList l,  void (*linklist_deallocator)(void*), DoubleLinkedList *head);
+
+#ifdef __cplusplus
+}
+#endif
index 90d2cbe51904320173a853d6e8f3ca92d83ed02a..4fd52bd4b51f4ccbebd82b932ecc896fd16f09ab 100644 (file)
 #include <sparse/LinkedList.h>
 #include <stdio.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct QuadTree_struct *QuadTree;
 
 struct QuadTree_struct {
@@ -55,3 +59,7 @@ void QuadTree_get_repulsive_force(QuadTree qt, double *force, double *x, double
 void QuadTree_get_nearest(QuadTree qt, double *x, double *ymin, int *imin, double *min, int *flag);
 
 QuadTree QuadTree_new_in_quadrant(int dim, double *center, double width, int max_level, int i);
+
+#ifdef __cplusplus
+}
+#endif
index 6093913506af5c51d959a9f7c93cab19236b4bab..2fbc1c6d4a16ed89960206dd7c1150838ccdd456 100644 (file)
 #include <sparse/general.h>
 #include <stdio.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define SYMMETRY_EPSILON 0.0000001
 enum {FORMAT_CSC, FORMAT_CSR, FORMAT_COORD};
 enum {UNMASKED = -10, MASKED = 1};
@@ -113,3 +117,7 @@ SparseMatrix SparseMatrix_from_dense(int m, int n, double *x);
 #define SparseMatrix_known_undirected(A) test_flag((A)->property, MATRIX_UNDIRECTED)
 #define SparseMatrix_known_symmetric(A) test_flag((A)->property, MATRIX_SYMMETRIC)
 #define SparseMatrix_known_strucural_symmetric(A) test_flag((A)->property, MATRIX_PATTERN_SYMMETRIC)
+
+#ifdef __cplusplus
+}
+#endif
index a8db9eece649c16c3e75b5510fe4ea21cf4953bd..1606cb04742ecd84d87a2ea5c69bb960579405c8 100644 (file)
 
 #pragma once
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct Multilevel_Modularity_Clustering_struct *Multilevel_Modularity_Clustering;
 
 struct Multilevel_Modularity_Clustering_struct {
@@ -49,3 +53,7 @@ enum {CLUSTERING_MODULARITY = 0, CLUSTERING_MQ};
 */
 void modularity_clustering(SparseMatrix A, int inplace, int maxcluster, int use_value,
                           int *nclusters, int **assignment, double *modularity, int *flag);
+
+#ifdef __cplusplus
+}
+#endif
index f77a918b3110a506f72664d27e5027448dc91592..778cf3c7a0f260e60a889e6e0431b68eaf054079 100644 (file)
 #pragma once
 
 #include "stdio.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 enum {MAX_COLOR = 1001};
 
 enum {npalettes = 265};
@@ -31,3 +36,7 @@ extern float palette_sequential_singlehue_red[1001][3];
 extern float palette_sequential_singlehue_red_lighter[1001][3];
 extern float palette_adam_blend[1001][3];
 extern float palette_adam[11][3];
+
+#ifdef __cplusplus
+}
+#endif
index 981eca40713b65b5a1289ad51463b7fe42a1c1e5..83c91924d5289766a20b4d6b58ae34049f592eb1 100644 (file)
 
 #include <color.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern int colorxlate(char *str, gvcolor_t * color, color_type_t target_type);
 
 void rgb2hex(float r, float g, float b, char *cstring, const char* opacity);
   /* dimension of cstring must be >=7 */
 
 char* hue2rgb(double hue, char *color);
+
+#ifdef __cplusplus
+}
+#endif
index bf0ea12d1646ba047d5c58d43f441ec0da397dd8..9990a4c94cf5e83c75442f47807e473969b0d401 100644 (file)
 #include <common/memory.h>
 #endif  /* STANDALONE */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define set_flag(a, flag) ((a)=((a)|(flag)))
 #define test_flag(a, flag) ((a)&(flag))
 #define clear_flag(a, flag) ((a) &=(~(flag)))
@@ -114,3 +118,7 @@ double point_distance(double *p1, double *p2, int dim);
 char *strip_dir(char *s);
 
 void scale_to_box(double xmin, double ymin, double xmax, double ymax, int n, int dim, double *x);
+
+#ifdef __cplusplus
+}
+#endif
index 5563e0002980eeae5041755a7af34ea6e33d8a87..fb57eec34704f523f65d479cd53c5c0c6f66a481 100644 (file)
 
 #pragma once
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct Multilevel_MQ_Clustering_struct *Multilevel_MQ_Clustering;
 
 struct Multilevel_MQ_Clustering_struct {
@@ -55,3 +59,7 @@ struct Multilevel_MQ_Clustering_struct {
 */
 void mq_clustering(SparseMatrix A, int inplace, int maxcluster, int use_value,
                           int *nclusters, int **assignment, double *mq, int *flag);
+
+#ifdef __cplusplus
+}
+#endif
index 80248b1601e8db3f864c6146711c6abdbf2bea18..9b2b0d84b7183e275f739a73c805f51788eaec7b 100644 (file)
 #pragma once
 
 #include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct vector_struct {
   int maxlen;
   int len;
@@ -35,3 +40,7 @@ void* Vector_get(Vector v, int i);
 int Vector_get_length(Vector v);
 
 Vector Vector_reset(Vector v, void *stuff, int i);
+
+#ifdef __cplusplus
+}
+#endif