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

net: compiler warning for _GNU_SOURCE #66785

Closed
rnhaddad opened this issue Apr 11, 2024 · 1 comment
Closed

net: compiler warning for _GNU_SOURCE #66785

rnhaddad opened this issue Apr 11, 2024 · 1 comment

Comments

@rnhaddad
Copy link

Go version

go1.21.5 linux/amd64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='amd64'
GOBIN=''
GOCACHE='~/go_cache/go-build'
GOENV='~/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='~/gopath/pkg/mod'
GOOS='linux'
GOPATH='~/gopath/'
GOROOT='~/go/1.21.5'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='~/go/1.21.5/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.5'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3819656890=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Compile CGO with "-D_GNU_SOURCE"

What did you see happen?

Compiler warning:
<0033706> /sw/packages/xr/go/1.21.5/src/net/cgo_unix_cgo.go:10:9: warning: '_GNU_SOURCE' macro redefined [-Wmacro-redefined]

What did you expect to see?

The warning is due to:

#define _GNU_SOURCE

The above should have been #ifndef #define, like here:

#ifndef _GNU_SOURCE // pthread_getattr_np

@seankhliao seankhliao changed the title Compiler warning for _GNU_SOURCE net: compiler warning for _GNU_SOURCE Apr 11, 2024
@ianlancetaylor
Copy link
Contributor

Closing as dup of #66325.

@ianlancetaylor ianlancetaylor closed this as not planned Won't fix, can't repro, duplicate, stale Apr 11, 2024
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

2 participants