d2r2 / go-dht

Golang library to interact with DHT11/DHT22/DHT12 temperature and humidity sensors from Raspberry PI.
MIT License
133 stars 52 forks source link

Golang compiler warnings for functions #15

Closed jnovack closed 5 years ago

jnovack commented 5 years ago
dht.go.h:304: warning: implicit declaration of function 'sched_setscheduler' is
              invalid in C99 [-Wimplicit-function-declaration]
dht.go.h:317: warning: implicit declaration of function 'sched_setscheduler' is
              invalid in C99 [-Wimplicit-function-declaration]
d2r2 commented 5 years ago

It looks strange. Function sched_setscheduler doesn't declared locally and taken from outside public API (#include http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html). We have here many other functions taken from outside, like write, memset, etc., and they do not have such warning.

I will not accept this change until no explanation will be found on this strange warning.

jnovack commented 5 years ago

I ran the following to produce the error.

$ go vet ./...
d2r2 commented 5 years ago

My go vet -v . produce no warning:

root@orangepizero:~/gocode/src/github.com/d2r2/go-dht# go vet -v .
github.com/d2r2/go-dht
# github.com/d2r2/go-dht
Checking file ./logger.go
Checking file $WORK/b001/_cgo_gotypes.go
Checking file $WORK/b001/dht.cgo1.go
Checking file $WORK/b001/_cgo_import.go
root@orangepizero:~/gocode/src/github.com/d2r2/go-dht# 

Could you run your go vet with -v option? And give me extra output of uname -a - I just curious what platform you use.

d2r2 commented 5 years ago

BTW, one person send me errors he got when he is trying to compile directly on macOS Mojave platform:

$ go get -u github.com/d2r2/go-dht ld: library not found for -lrt clang: error: linker command failed with exit code 1 (use -v to see invocation) In file included from ../../d2r2/go-dht/dht.go:3: ../../d2r2/go-dht/dht.go.h:304:15: warning: implicit declaration of function 'sched_setscheduler' is invalid in C99 [-Wimplicit-function-declaration] ../../d2r2/go-dht/dht.go.h:317:15: warning: implicit declaration of function 'sched_setscheduler' is invalid in C99 [-Wimplicit-function-declaration]

As you can see there are some additional warnings with sched_setscheduler function. That is why I am asking you to send me uname -a extra output.

jnovack commented 5 years ago

I'm on Mojave as well. It makes sense that sched_setscheduler is not warning on linux.

d2r2 commented 5 years ago

Hi @jnovack! I have merged new feature, that should resolve issue with compilation on macOS. Could you find a time to get latest version of go-dht and try to compile it on macOS Mojave? Thanks!