Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cgo: build typedef fail in clang but ok in gcc #20129

fastfading opened this issue Apr 26, 2017 · 3 comments


Copy link

commented Apr 26, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go 1.8

What operating system and processor architecture are you using (go env)?

mac os 10 & ubuntu 16.04

What did you do?

package main

#include <stdlib.h>
#include <stdio.h>
typedef void GLvoid;
GLvoid Foo() {
import "C"

func main() {

CC=clang CGO_ENABLE=1 go build -v void.go -->fail


./void.go:47:10: error: field has incomplete type 'GLvoid' (aka 'void')

CC=gcc CGO_ENABLE=1 go build -o void -v void.go -->ok

What did you expect to see?

all build ok in both gcc and clang

What did you see instead?

clang build fail but gcc ok


This comment has been minimized.

Copy link

commented Apr 26, 2017

gcc --version
gcc (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005
but build fail on mac
gcc --version

Configured with: --prefix=/Applications/ --with-gxx-include-dir=/usr/include/c++/4.2.1

Apple LLVM version 8.0.0 (clang-800.0.42.1)

Target: x86_64-apple-darwin15.5.0

Thread model: posix

@ALTree ALTree changed the title cgo build typedef fail in clang but ok in gcc cmd/cgo: build typedef fail in clang but ok in gcc Apr 26, 2017

This comment has been minimized.

Copy link

commented Apr 27, 2017

For some reason clang seems to be emitting DW_TAG_typedef without actually saying what it is a typedef for.

<1><6a>: Abbrev Number: 6 (DW_TAG_typedef)
    <6b>   DW_AT_name        : (indirect string, offset: 0x8c): GLvoid
    <6f>   DW_AT_decl_file   : 1
    <70>   DW_AT_decl_line   : 2

Perhaps it does that for any typedef of void?

@ianlancetaylor ianlancetaylor added this to the Go1.9 milestone Apr 27, 2017

This comment has been minimized.

Copy link

commented Jun 4, 2017

CL mentions this issue.

@gopherbot gopherbot closed this in 289a871 Jun 27, 2017
@golang golang locked and limited conversation to collaborators Jun 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
4 participants
You can’t perform that action at this time.