c-for-go icon indicating copy to clipboard operation
c-for-go copied to clipboard

error parsing std libraries

Open terinjokes opened this issue 7 years ago • 10 comments

I'm trying to rebuild the generated bindings in xlab/vorbis-go, but I'm having some difficulties with the std headers.

After modifying the call the to c-for-go:

c-for-go --ccincl vorbis.yml

I get the following errors:

processing vorbis.yml ⠹/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:34:6: called object is not a function or function pointer (have 'int')
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:34:5: not a constant expression
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:48:6: called object is not a function or function pointer (have 'int')
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:48:5: not a constant expression
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:51:26: unexpected identifier ptrdiff_t, expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:59:6: called object is not a function or function pointer (have 'int')
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:59:5: not a constant expression
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:71:29: called object is not a function or function pointer (have 'int')
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:70:5: not a constant expression
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:84:6: called object is not a function or function pointer (have 'int')
too many errors

It seems this project has trouble with the headers of Clang 6.

terinjokes avatar Apr 22 '18 20:04 terinjokes

Just for note: generates fine with default Apple LLVM, I do not use --ccincl (see Makefile)

$ clang -v
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

@terinjokes could you please post snippets or the whole file somewhere? Also please try -ccdefs and -ccincl flags (in different combinations):

c-for-go vorbis.yml
c-for-go --ccincl vorbis.yml
c-for-go --ccdefs vorbis.yml
c-for-go --ccincl --ccdefs vorbis.yml

xlab avatar Apr 22 '18 21:04 xlab

c-for-go vorbis.yml

processing vorbis.yml ⠋[ERR] /data/data/com.termux/files/usr/include/stdint.h:33:10: include file not found: stddef.h. Search paths:
        /usr/include
        /data/data/com.termux/files/usr/include
        /data/data/com.termux/files/home/go/src/github.com/xlab/vorbis-go
        /usr/include
        /data/data/com.termux/files/usr/include
        /data/data/com.termux/files/home/go/src/github.com/xlab/vorbis-go (and 3 more errors)

--ccincl

included above

--ccdefs

processing vorbis.yml ⠹[ERR] /data/data/com.termux/files/usr/include/inttypes.h:268:33: unexpected '*', expected one of ['(', ')', ',', ':', ';', '=', '[', '{', _Bool, _Complex, _Noreturn, _Static_assert, asm, auto, char, const, double, enum, extern, float, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile] (and 3 more errors)

--ccincl --ccdefs

processing vorbis.yml ⠹/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:34:6: called object is not a function or function pointer (have 'int')
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:34:5: not a constant expression
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:48:6: called object is not a function or function pointer (have 'int')
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:48:5: not a constant expression
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:59:6: called object is not a function or function pointer (have 'int')
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:59:5: not a constant expression
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:71:29: called object is not a function or function pointer (have 'int')
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:70:5: not a constant expression
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:84:6: called object is not a function or function pointer (have 'int')
/data/data/com.termux/files/usr/lib/clang/6.0.0/include/stddef.h:84:5: not a constant expression
too many errors

stddef.h

stddef.h hasn't changed in a number of years, and my version is a byte-for-byte match with master.

terinjokes avatar Apr 22 '18 22:04 terinjokes

include file not found: stddef.h. Search paths:
        /usr/include

On my machine, that file is available at:

/usr/include/stddef.h
/*
 * Copyright (c) 2000-2013 Apple Inc. All rights reserved.
 *
 * @APPLE_LICENSE_HEADER_START@
 * 

Will check out your stddef..

xlab avatar Apr 22 '18 22:04 xlab

Hey, just wanted to point out that on my system stddef.h is not located in /usr/include either. It's dependent on the compiler in question, so for me it's located under /usr/lib/gcc/x86_64-pc-linux-gnu//include, so I had to manually add that to the include paths. Apple's Clang probably assumes that it is the only compiler installed on the system and places its stddef.h in /usr/include.

jclc avatar Oct 18 '18 18:10 jclc

Hello! Trying to make a change to the vulkan-go manifest and getting this issue when I try to rebuild. I'm using Mojave 10.14.2. Clang gives me:

$ clang -v
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

c-for-go -ccdefs -out .. vulkan.yml

  processing vulkan.yml ⠹[ERR] vulkan/vk_platform.h:71:10: include file not found: stddef.h. Search paths:
	/usr/include
	/Users/noofapple/go/src/github.com/vulkan-go/vulkan
	/usr/include
	/Users/noofapple/go/src/github.com/vulkan-go/vulkan (and 2 more errors)
make: *** [all] Error 1

c-for-go -ccdefs -ccincl -out .. vulkan.yml

  processing vulkan.yml ⠙/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/include/stddef.h:34:6: called object is not a function or function pointer (have 'int')
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/include/stddef.h:34:5: not a constant expression
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/include/stddef.h:48:6: called object is not a function or function pointer (have 'int')
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/include/stddef.h:48:5: not a constant expression
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/include/stddef.h:59:6: called object is not a function or function pointer (have 'int')
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/include/stddef.h:59:5: not a constant expression
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/include/stddef.h:71:29: called object is not a function or function pointer (have 'int')
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/include/stddef.h:70:5: not a constant expression
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/include/stddef.h:84:6: called object is not a function or function pointer (have 'int')
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/include/stddef.h:84:5: not a constant expression
too many errors
make: *** [all] Error 1

Noofbiz avatar Jan 03 '19 02:01 Noofbiz

The issue seems to be coming from the __has_feature(modules) macro for Clang. Is your stddef.h the Clang or GCC version?

ETA: Mine seems to be a copy of the one linked above. With the copyright (c) 2008 Eli Friedman header.

Noofbiz avatar Jan 30 '19 19:01 Noofbiz

I have exactly the same problem as @Noofbiz on Mojave 10.14.6, and I don't have /usr/include/stddef.h.

RobinWragg avatar Apr 21 '20 11:04 RobinWragg

@RobinWragg I believe nobody has now, Catalina nuked /usr/include and there was some investigation in progress how to parse XCode internal includes that may contain weird macros: https://github.com/xlab/c-for-go/issues/84

You may try something like

PARSER: 
  IncludePaths: [
    "/usr/include",
    "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
  ]

xlab avatar Apr 21 '20 11:04 xlab

@xlab thanks for the suggestion. After I added the full include path, I get the same errors as @terinjokes at the top of this thread, i.e. issues with parsing stddef.h.

RobinWragg avatar Apr 21 '20 14:04 RobinWragg

@xlab I am also getting similar errors as stated above after including /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include

image

sys/socket.h:722 image

audiolion avatar May 06 '20 19:05 audiolion