Is there something like macros in C ++, like #ifdef, so I can choose what to build based on a flag?

I need to build on linux and windows with different packages the same file on windows i need import github.com/hashicorp/go-syslogon linux tooimport log/syslog

and inside the code in the file I have to use syslog.ALERTor gsyslog.ALERTdepending on os. Is there Gosomething like macros in C++, for example #ifdef, so I can choose what to build on the basis of the flag? How to achieve this without the same file in order to have different content for OS-based builds?

+4
source share
2 answers

Here's what tag creation is for:

, , ,

// +build

, . ( Go), , . , Go .

OS/arch - GOOS GOARCH:

GOARCH - : 386, amd64 arm.

GOOS - : darwin, freebsd, linux ..

+8

, .

,

// +build linux

, Linux.

// +build windows

.

. .

+4

All Articles