V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
lysS
V2EX  ›  问与答

CGO 怎么写,指语法提示不太能工作

  •  
  •   lysS · 2022-06-01 10:27:06 +08:00 · 822 次点击
    这是一个创建于 666 天前的主题,其中的信息可能已经有所发展或是发生改变。

    VSCode 写 CGO, 一般 C.xxxx 都会报红,而且也转不到中间代码的实现。但不知道为什么有的时候有可以。

    还有就是问问一下 goland 对 CGO 支持好吗?

    lysS
        1
    lysS  
    OP
       2022-06-01 10:32:29 +08:00
    解决了,
    这样就可以:
    // #cgo CFLAGS: -I./include
    // #include "sciter-x.h"
    import "C"
    import "fmt"


    而以前我是这样的:
    import "fmt"

    // #cgo CFLAGS: -I./include
    // #include "sciter-x.h"
    import "C"

    参考: https://stackoverflow.com/questions/58505317/vscode-import-c-fails-on-modules

    怪欸!!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   979 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 20:12 · PVG 04:12 · LAX 13:12 · JFK 16:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.