tinygo-org / tinygo

Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
https://tinygo.org
Other
14.82k stars 872 forks source link

type C.bool is undfined #3956

Closed Patrick0308 closed 5 months ago

Patrick0308 commented 9 months ago

Environment:

tinygo version: 0.30.0 operating System: macOS architecture: aarch64

Description:

Compilation brakes with an undefined C._Bool

Steps to reproduce:

Given the following Go-code:

package main

/*
  #include "stdbool.h"
*/
import "C"

import "fmt"

func main() {
    fmt.Printf("%s", C.bool(true))
}

Run

tinygo run main.go

Expected behavior:

❯ tinygo run main.go
%!s(main._Ctype__Bool=true)%    

Actual behavior:

❯ tinygo run main.go
# command-line-arguments
../../../../opt/homebrew/Cellar/tinygo/0.30.0/lib/clang/include/stdbool.h:20:14: undefined: C._Bool
Gustavomurta commented 9 months ago

I´m not SW expert, but searching this argument - #include "stdbool.h" , I found this:

include (In Go, this syntax is different)

Patrick0308 commented 9 months ago

https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html

The difference between "stdbool.h" and is searching path. However it doesn't matter on this case.

failed too.
deadprogram commented 9 months ago

This was corrected in https://github.com/tinygo-org/tinygo/pull/3928 which will be part of the next release.

Patrick0308 commented 9 months ago

@deadprogram I tested with dev branch. This case still failed.

deadprogram commented 5 months ago

Completed with v0.31.0 so now closing. Thank you!