blob: 24caab4711386067aed7d638d84785a3bcbc6312 [file] [log] [blame]
Colin Cross7bb052a2015-02-03 12:59:37 -08001// Copyright 2013 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// Test that the #cgo CFLAGS directive works,
6// with and without platform filters.
7// See http://code.google.com/p/go/issues/detail?id=5224 for details.
8package cgotest
9
10/*
11#cgo CFLAGS: -DCOMMON_VALUE=123
12#cgo windows CFLAGS: -DIS_WINDOWS=1
13#cgo !windows CFLAGS: -DIS_WINDOWS=0
14int common = COMMON_VALUE;
15int is_windows = IS_WINDOWS;
16*/
17import "C"
18
19import (
20 "runtime"
21 "testing"
22)
23
24func testCflags(t *testing.T) {
25 is_windows := C.is_windows == 1
26 if is_windows != (runtime.GOOS == "windows") {
27 t.Errorf("is_windows: %v, runtime.GOOS: %s", is_windows, runtime.GOOS)
28 }
29 if C.common != 123 {
30 t.Errorf("common: %v (expected 123)", C.common)
31 }
32}