digitalocean / prometheus-client-c

A Prometheus Client in C
Other
160 stars 79 forks source link

macos not build (error: incompatible pointer types passing '_Atomic(double) *' to parameter of type 'double) #50

Open fengve opened 3 years ago

fengve commented 3 years ago

/Users/fengwei/prometheus-client-c/prom/src/prom_metric_sample.c:69:54: error: incompatible pointer types passing '_Atomic(double) ' to parameter of type 'double ' [-Werror,-Wincompatible-pointer-types] if (atomic_compare_exchange_weak(&self->r_value, &old, new)) { ^~~~ /Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/include/stdatomic.h:143:108: note: expanded from macro 'atomic_compare_exchange_weak'

define atomic_compare_exchange_weak(object, expected, desired) __c11_atomic_compare_exchange_weak(object, expected, des...

                                                                                                       ^~~~~~~~

/Users/fengwei/prometheus-client-c/prom/src/prom_metric_sample.c:84:54: error: incompatible pointer types passing '_Atomic(double) ' to parameter of type 'double ' [-Werror,-Wincompatible-pointer-types] if (atomic_compare_exchange_weak(&self->r_value, &old, new)) { ^~~~ /Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/include/stdatomic.h:143:108: note: expanded from macro 'atomic_compare_exchange_weak'

define atomic_compare_exchange_weak(object, expected, desired) __c11_atomic_compare_exchange_weak(object, expected, des...

--------------------clang version-------------------------------- Apple clang version 11.0.0 (clang-1100.0.33.8) Target: x86_64-apple-darwin19.6.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

---------------os-------------- Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64

czheji commented 3 years ago

_atomicload should return a bare type, which should be corrected to: double old = atomic_load(&self->r_value);

eakraly commented 2 years ago

Fix in #71