tinygo icon indicating copy to clipboard operation
tinygo copied to clipboard

type C.bool is undfined

Open Patrick0308 opened this issue 2 years ago • 4 comments

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

Patrick0308 avatar Oct 16 '23 06:10 Patrick0308

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

#include <stdbool.h> (In Go, this syntax is different)

Gustavomurta avatar Oct 17 '23 12:10 Gustavomurta

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

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

Patrick0308 avatar Oct 20 '23 11:10 Patrick0308

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

deadprogram avatar Oct 23 '23 18:10 deadprogram

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

Patrick0308 avatar Oct 24 '23 06:10 Patrick0308

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

deadprogram avatar Feb 28 '24 07:02 deadprogram