Giter Site home page Giter Site logo

Comments (18)

leedenison avatar leedenison commented on July 17, 2024 1

I had a similar issue, but seemed to progress by defining _POSIX_C_SOURCE which sets _DARWIN_C_LEVEL and skips the Darwin extensions.

PARSER:
  Defines:
    _POSIX_C_SOURCE: 1

from c-for-go.

1l0 avatar 1l0 commented on July 17, 2024

Same but for stdbool.h.

from c-for-go.

xlab avatar xlab commented on July 17, 2024

Install Command Line Tools from there
https://developer.apple.com/download/more/

from c-for-go.

ePirat avatar ePirat commented on July 17, 2024

I have them installed. Xcode too. I have a full development environment set-up and can compile C, C++, Objective C fine with it.

Just to make sure, I checked with xcode-select:

xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

from c-for-go.

1l0 avatar 1l0 commented on July 17, 2024

Same:

$ pwd
/Applications/Xcode.app/Contents/Developer
$ find . -name stdbool.h
./Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/4.2.1/tr1/stdbool.h
./Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1/tr1/stdbool.h
./Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/2.0/include/stdbool.h
./Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/stdbool.h
./Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/4.2.1/tr1/stdbool.h
./Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/stdbool.h
./Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include/stdbool.h

from c-for-go.

xlab avatar xlab commented on July 17, 2024

I'm reopening this so I won't look like a complete douche. But I still believe the problem is in your environment configuration.

Normally stdio.h is located in /usr/include when Command Line Tools are installed. I did that for myself a couple of hours ago, after updating my Xcode to the newest.

$ find /usr/include -name "stdio.h"
/usr/include/c++/4.2.1/tr1/stdio.h
/usr/include/sys/stdio.h
/usr/include/stdio.h

I don't understand why you're looking in /Applications/Xcode.app/Contents/Developer path, since these paths are for Objective-C development. If you are using a UNIX-style toolchain, after installing Command Line Tools your import path is /usr/include and /usr/local/include.

From CLT description:

This package enables UNIX-style development via Terminal by installing command
line developer tools, as well as macOS SDK frameworks and headers. Many useful
tools are included, such as the Apple LLVM compiler, linker, and Make. If you use
Xcode, these tools are also embedded within the Xcode IDE.

They are embedded, but for proper development it's important to use /usr-based tools.

E.g.

$ which gcc
/usr/bin/gcc
$ which make
/usr/bin/make

from c-for-go.

xlab avatar xlab commented on July 17, 2024

@1l0 stdbool.h is another issue, just place this stub into your bindings directory:
https://gist.github.com/xlab/e5f1f1f4bdc7568af5b1c81a305a1e7d

#ifndef STDBOOL_H
#define STDBOOL_H

typedef int bool;
#define true 1
#define false 0

#endif // STDBOOL_H

There is no stdbool header easily available on OS X.

from c-for-go.

xlab avatar xlab commented on July 17, 2024

@ePirat your situation seems weird, I have no issues on OS X with this manifest:

--- 
GENERATOR: 
  PackageName: foo
  Includes: ["stdio.h"]

PARSER: 
  IncludePaths: ["/usr/include"]
  SourcesPaths: ["/usr/include/stdio.h"]
c-for-go foo.yml

Could you please share a reproducible example of YAML + headers? You can e-mail them to me.

from c-for-go.

ePirat avatar ePirat commented on July 17, 2024

What I am trying to do is generate the headers for the VLC plugin headers.

I've removed the Xcode include path now, so I have now:

IncludePaths: ["/usr/include"]

which does work, but now I get:

include file not found: stdarg.h

So I tried adding "/usr/include/c++/4.2.1/tr1" as that contains stdarg.h, but with that I got:

[ERR] /usr/include/c++/4.2.1/tr1/stdarg.h:37:10: include file not found: tr1/cstdarg.

When omitting -ccdefs, it seem to kinda work. (Still getting errors but probably because I need to work more on the Translator section in my config?)

from c-for-go.

ePirat avatar ePirat commented on July 17, 2024

Hm, seems I can't get this to work properly, getting errors after errors and right when solving one, running into another…

In case anyone can offer some advice, that's how the yaml looks right now:

--- 
GENERATOR: 
  PackageName: vlc-plugin
  PackageDescription: "Package vlc-plugin provides Go bindings for VLC plugin implementations"
  PackageLicense: "THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS."
  PkgConfigOpts: [vlc-plugin]
  Includes: ["vlc_common.h"]

PARSER: 
  IncludePaths: ["/usr/include"]
  SourcesPaths: ["vlc_common.h", "vlc_messages.h"]

TRANSLATOR: 
  ConstRules: 
    defines: expand
    enum: expand

I've tried adding some more IncludePaths, running with or without -ccdefs, but so far getting tons of errors.
I am already using VLC plugin headers with success in Go, as can be seen here, but was hoping I could use c-for-go to reduce boilerplate code I will have to write, to wrap the C functions.

The VLC headers can be found here: vlc.zip

I was hoping to be able to get at least some sort of result, which I could then further improve using the Translator settings, but without any result at all and a lot of weird errors when parsing system headers, I have no clue how to continue.

from c-for-go.

xlab avatar xlab commented on July 17, 2024

Anything from /usr/include/c++/4.2.1/tr1 or similar won't work, it's a private path for compiler.

I will get back to you soon, about the issues related to the code.

from c-for-go.

1l0 avatar 1l0 commented on July 17, 2024

I was looking in /Applications/Xcode.app/Contents/Developer because c-for-go --ccincl pointed out that path. After adding /usr/include I'm in the same situation with #41 (comment).
I uploaded a repo that don't work.

from c-for-go.

1l0 avatar 1l0 commented on July 17, 2024

I've finally managed by just adding following defines:

PARSER:
  Defines:
    __has_include_next(x): 1

No /usr/include, just --ccincl.
I've not tested further but at least succeeded to generate the Go package.

from c-for-go.

xlab avatar xlab commented on July 17, 2024

Ok, it works fine on my OS X though without additional flags or defines.

I cloned your package https://github.com/1l0/godot on commit d136ba5, added two files to its root:

Added this to PARSER section:

PARSER:
  IncludePaths: 
    - /usr/include

Generated with

$ c-for-go -out .. godot.yml

No XCode or __has_include_next(x) was involved.

See 1l0/godot#1

from c-for-go.

1l0 avatar 1l0 commented on July 17, 2024

It works for me too without --ccincl in that way. So we should just add stubs. Thanks for helping.

from c-for-go.

jancona avatar jancona commented on July 17, 2024

I'm seeing this issue. Here's the output with the YAML from the comment above:

$ xcode-select -v
xcode-select version 2349.
$ xcode-select -p
/Applications/Xcode.app/Contents/Developer
$ cat foo.yml
---
GENERATOR:
  PackageName: foo
  Includes: ["stdio.h"]

PARSER:
  IncludePaths: ["/usr/include"]
  SourcesPaths: ["/usr/include/stdio.h"]
$ c-for-go --ccdefs foo.yml
  processing foo.yml ⠼[ERR] /usr/include/stdio.h:372:16: unexpected char, expected one of [',', ';', '=']
$

Anything else I should try to troubleshoot?

from c-for-go.

xlab avatar xlab commented on July 17, 2024

@jancona Hi, please share stdio.h here, I think my file is different — no line at /usr/include/stdio.h:372:16

from c-for-go.

jancona avatar jancona commented on July 17, 2024

Thanks! Here's the file: stdio.h.zip
I'm running High Sierra version 10.13.6

from c-for-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.