Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows build #61

Open
andysCaplin opened this issue Sep 3, 2021 · 0 comments
Open

Windows build #61

andysCaplin opened this issue Sep 3, 2021 · 0 comments

Comments

@andysCaplin
Copy link

We want to use the library on Windows and I found that if the code below is conditionally excluded for WIN32 the library will build and work on Windows. Would it be possible to add this change or something similar to the code.

diff --git a/prom/src/prom_collector.c b/prom/src/prom_collector.c
index dce3bb4..f3bd8cf 100644
--- a/prom/src/prom_collector.c
+++ b/prom/src/prom_collector.c
@@ -15,7 +15,9 @@
  */

 #include <stdio.h>
+#ifndef WIN32
 #include <unistd.h>
+#endif

 // Public
 #include "prom_alloc.h"
@@ -119,6 +121,7 @@ int prom_collector_add_metric(prom_collector_t *self, prom_metric_t *metric) {
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Process Collector

+#ifndef WIN32
 prom_map_t *prom_collector_process_collect(prom_collector_t *self);

 prom_collector_t *prom_collector_process_new(const char *limits_path, const char *stat_path) {
@@ -275,3 +278,4 @@ prom_map_t *prom_collector_process_collect(prom_collector_t *self) {

   return self->metrics;
 }
+#endif
diff --git a/prom/src/prom_collector_registry.c b/prom/src/prom_collector_registry.c
index 4c2bc2d..a99573f 100644
--- a/prom/src/prom_collector_registry.c
+++ b/prom/src/prom_collector_registry.c
@@ -61,6 +61,7 @@ prom_collector_registry_t *prom_collector_registry_new(const char *name) {
   return self;
 }

+#ifndef WIN32
 int prom_collector_registry_enable_process_metrics(prom_collector_registry_t *self) {
   PROM_ASSERT(self != NULL);
   if (self == NULL) return 1;
@@ -87,14 +88,17 @@ int prom_collector_registry_enable_custom_process_metrics(prom_collector_registr
   }
   return 1;
 }
+#endif

 int prom_collector_registry_default_init(void) {
   if (PROM_COLLECTOR_REGISTRY_DEFAULT != NULL) return 0;

   PROM_COLLECTOR_REGISTRY_DEFAULT = prom_collector_registry_new("default");
+#ifndef WIN32
   if (PROM_COLLECTOR_REGISTRY_DEFAULT) {
     return prom_collector_registry_enable_process_metrics(PROM_COLLECTOR_REGISTRY_DEFAULT);
   }
+#endif
   return 1;
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant