Hey, i am getting this
> go build .
github.com/go-gl/gl/v3.2-core/gl
github.com/golang-ui/nuklear/nk
# github.com/golang-ui/nuklear/nk
cgo-dwarf-inference:1:17: error: expected '{' before ')' tokenwas checking the nk-example.
Activity
7Getting this exact error as well from my own code just by having the inclusion. My go.mod looks like:
module test/nktest
go 1.22.5
require (
github.com/golang-ui/nuklear v0.0.0-20231115163627-2440a671efc5
github.com/veandco/go-sdl2 v0.4.40
)
require (
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71 // indirect
github.com/go-gl/glfw v0.0.0-20240506104042-037f3cc74f2a // indirect
github.com/xlab/android-go v0.0.0-20221106204035-3cc54d5032fa // indirect
)and my import looks like:
import (
"log"
"os"
"regexp"
"runtime"
"strconv"
"strings"
"github.com/golang-ui/nuklear/nk"
"github.com/veandco/go-sdl2/sdl"
)Even go install github.com/golang-ui/nuklear/nk simply triggers this error without it being present in imports.
Tried indirects as well, same result.
SDL2 example doesn't work either. It seems like the functions are based on some older nuklear api version, the arguments provided in the examples doesn't match the current api.
Probably I see the same error.
% go mod init github.com/golang-ui/nuklear
% go mod tidy
% go build ./nk
# github.com/go-gl/glfw/v3.2/glfw
In file included from ../../go/pkg/mod/github.com/go-gl/glfw@v0.0.0-20240506104042-037f3cc74f2a/v3.2/glfw/c_glfw_darwin.go:8:
../../go/pkg/mod/github.com/go-gl/glfw@v0.0.0-20240506104042-037f3cc74f2a/v3.2/glfw/glfw/src/cocoa_window.m:989:9: warning: multiple methods named 'center' found [-Wobjc-multiple-method-names]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSCollectionViewCompositionalLayout.h:602:19: note: using
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:417:1: note: also found
# github.com/golang-ui/nuklear/nk
cgo-dwarf-inference:1:17: error: expected identifier or '{'
__typeof__(enum ) *__cgo__0;
^
cgo-dwarf-inference:1:28: error: expected ')'
__typeof__(enum ) *__cgo__0;
^
cgo-dwarf-inference:1:11: note: to match this '('
__typeof__(enum ) *__cgo__0;
^
2 errors generated.My environment is like this:
% go version
go version go1.23.2 darwin/arm64% fastfetch
..' hajimehoshi@Hajimes-MacBook-Pro
,xNMM. -------------------------------
.OMMMMo OS: macOS 15.0.1 arm64
lMM" Host: MacBook Pro (14-inch, Nov 2023, Three Thunderbolt 4 ports)
.;loddo:. .olloddol;. Kernel: 24.0.0
cKMMMMMMMMMMNWMMMMMMMMMM0: Uptime: 9 days, 14 hours, 12 mins
.KMMMMMMMMMMMMMMMMMMMMMMMWd. Packages: 148 (brew), 2 (brew-cask)
XMMMMMMMMMMMMMMMMMMMMMMMX. Shell: zsh 5.9
;MMMMMMMMMMMMMMMMMMMMMMMM: Display (Color LCD): 3600x2338 @ 120Hz (as 1800x1169) [Built-in]
:MMMMMMMMMMMMMMMMMMMMMMMM: DE: Aqua
.MMMMMMMMMMMMMMMMMMMMMMMMX. WM: Quartz Compositor
kMMMMMMMMMMMMMMMMMMMMMMMMWd. WM Theme: Multicolor (Light)
'XMMMMMMMMMMMMMMMMMMMMMMMMMMk Font: .AppleSystemUIFont [System], Helvetica [User]
'XMMMMMMMMMMMMMMMMMMMMMMMMK. Cursor: Fill - Black, Outline - White (32px)
kMMMMMMMMMMMMMMMMMMMMMMd Terminal: tmux 3.3a
;KMMMMMMMWXXWMMMMMMMk. CPU: Apple M3 Pro (12) @ 4.06 GHz
"cooc*" "*coo'" GPU: Apple M3 Pro (18) [Integrated]
Memory: 15.12 GiB / 18.00 GiB (84%)
Swap: 15.35 GiB / 16.00 GiB (96%)
Disk (/): 320.35 GiB / 926.35 GiB (35%) - apfs [Read-only]
Local IP (en0): 192.168.0.10/24 *
Battery: 80% [AC connected]
Power Adapter: 96W USB-C Power Adapter
Locale: CI guess c-for-go failed to treat enums correctly:
// NkInputKey function as declared in nk/nuklear.h:837
func NkInputKey(arg0 *Context, arg1 C.enum_, down Bool) {
carg0, carg0AllocMap := (*C.struct_nk_context)(unsafe.Pointer(arg0)), cgoAllocsUnknown
carg1, carg1AllocMap := (C.enum_)(arg1), cgoAllocsUnknown
cdown, cdownAllocMap := (C.nk_bool)(down), cgoAllocsUnknown
C.nk_input_key(carg0, carg1, cdown)
runtime.KeepAlive(cdownAllocMap)
runtime.KeepAlive(carg1AllocMap)
runtime.KeepAlive(carg0AllocMap)
}One of the necessary changes is
diff --git a/nk.yml b/nk.yml
index 237576e..bebea9b 100644
--- a/nk.yml
+++ b/nk.yml
@@ -70,6 +70,7 @@ TRANSLATOR:
- {transform: export}
const:
- {action: accept, from: "(?i)^nk_"}
+ - {action: replace, from: "(?i)^nk_bool", to: "BoolType"}
- {action: replace, from: "(?i)^nk_", to: _}
- {action: ignore, from: _INT8}
- Even with the PR https://github.com/xlab/c-for-go/pull/176 and the above patch, I have not succeeded to compile this yet:
% go build ./nk
# github.com/golang-ui/nuklear/nk
nk/etc.go:26:26: cannot use content (variable of type string) as *byte value in argument to NkTexteditPaste
nk/impl_glfw_common.go:40:9: not enough return values
have (string)
want (string, error)
nk/impl_glfw_common.go:111:26: cannot use keyPressed(win, glfw.KeyDelete) (value of type int32) as Bool value in argument to NkInputKey
nk/impl_glfw_common.go:112:28: cannot use keyPressed(win, glfw.KeyEnter) (value of type int32) as Bool value in argument to NkInputKey
nk/impl_glfw_common.go:113:28: cannot use keyPressed(win, glfw.KeyKPEnter) (value of type int32) as Bool value in argument to NkInputKey
nk/impl_glfw_common.go:114:26: cannot use keyPressed(win, glfw.KeyTab) (value of type int32) as Bool value in argument to NkInputKey
nk/impl_glfw_common.go:115:32: cannot use keyPressed(win, glfw.KeyBackspace) (value of type int32) as Bool value in argument to NkInputKey
nk/impl_glfw_common.go:116:25: cannot use keyPressed(win, glfw.KeyUp) (value of type int32) as Bool value in argument to NkInputKey
nk/impl_glfw_common.go:117:27: cannot use keyPressed(win, glfw.KeyDown) (value of type int32) as Bool value in argument to NkInputKey
nk/impl_glfw_common.go:118:32: cannot use keyPressed(win, glfw.KeyHome) (value of type int32) as Bool value in argument to NkInputKey
nk/impl_glfw_common.go:118:32: too many errors
The same happens to me.
Build example:
Import go example:
Notes:
go1.22.5)