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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 warning: 'TARGET_OS_MAC' is not defined, evaluates to 0 [-Wundef-prefix=TARGET_OS_] #1571

Closed
AliYusuf95 opened this issue Oct 10, 2021 · 0 comments 路 Fixed by #1572
Closed

Comments

@AliYusuf95
Copy link
Contributor

Fiber version
v2.20.1

Issue description
If I use monitor middleware and try to build my project on macOS using LLVM/Clang 11.0 or higher (in my case 12.0.0), I get the following error:

# github.com/gofiber/fiber/v2/internal/gopsutil/cpu
../../Go/pkg/mod/github.com/gofiber/fiber/v2@v2.20.1/internal/gopsutil/cpu/cpu_darwin_cgo.go:13:5: warning: 'TARGET_OS_MAC' is not defined, evaluates to 0 [-Wundef-prefix=TARGET_OS_]

Code snippet

package main

import (
	"log"
	"github.com/gofiber/fiber/v2"
	"github.com/gofiber/fiber/v2/middleware/monitor"
)

func main() {
	app := fiber.New()
	
	app.Get("/dashboard", monitor.New())
	
	log.Fatal(app.Listen(":3000"))
}

Proposed Solution
Based on this issue it seems adding #include <TargetConditionals.h> before using TARGET_OS_MAC solves the problem.
As a workaround calling CGO_CFLAGS=-Wno-undef-prefix go build remove the warning message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants