Giter Site home page Giter Site logo

Comments (12)

xlab avatar xlab commented on July 17, 2024

Hi, thanks for the report, the error you're getting looks like this:

$ c-for-go libproc.yaml
  processing libproc.yaml ⠦[ERR] /usr/include/net/if.h:163:17: cannot determine size of struct if_data (and 5 more errors)

It's a result of CC was unable to understand header file, as some defines are not there. In this case it's required to run c-for-go with defines copied from GCC environment:

$ c-for-go -ccdefs libproc.yaml

I'm currently investigating what's the problem now with these defs

  processing libproc.yaml ⠦[ERR] /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_fd_def.h:54:1: unexpected '{', expected one of [',', ';', '=']

from c-for-go.

xlab avatar xlab commented on July 17, 2024

@tejasmanohar

  1. Please update c-for-go by running go get -u github.com/xlab/c-for-go, I added a non-related fix

  2. If you wish to proceed, you can remove the function at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_fd_def.h:54 it will generate with no problems after that. I'll study the problem with that function

UPD: resolved with 4af7464

from c-for-go.

xlab avatar xlab commented on July 17, 2024

IncludePaths: ["/usr/include",

This is also redundant

from c-for-go.

tejasmanohar avatar tejasmanohar commented on July 17, 2024
/* This inline avoids argument side-effect issues with FD_ISSET() */
/* static __inline int
__darwin_fd_isset(int _n, const struct fd_set *_p)
{
	return (_p->fds_bits[(unsigned long)_n/__DARWIN_NFDBITS] & ((__int32_t)(((unsigned long)1)<<((unsigned long)_n % __DARWIN_NFDBITS))));
}*/

seems to not generate after changing that file to look like this ^ ?

Tejas-Macbook:_reference tejas$ c-for-go libproc.yaml
processing libproc.yaml ⠼[ERR] /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/net/if.h:163:17: cannot determine size of struct if_data (and 7 more errors)

from c-for-go.

tejasmanohar avatar tejasmanohar commented on July 17, 2024

if.h on my computer https://gist.github.com/tejasmanohar/9511878258b4ec21440316592ef7cfd2

from c-for-go.

xlab avatar xlab commented on July 17, 2024

I addressed this exact issue in previous comment:

it's required to run c-for-go with defines copied from GCC environment:

$ c-for-go -ccdefs libproc.yaml

note the -ccdefs flag, please try with it

P.S. flag doc:

Options:
  -ccdefs
    	Use built-in defines from a hosted C-compiler.

it steals defines from host GCC.

from c-for-go.

tejasmanohar avatar tejasmanohar commented on July 17, 2024

Oops, sorry. I only saw your 2nd, 3rd comment. Not your first.

I tried with that flag and got

  processing libproc.yaml ⠴[ERR] /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/_types/_fd_def.h:54:1: unexpected '{', expected one of [',', ';', '=']

(another fd_def.h) -> so I changed that fd_def.h the same way but I got

  processing libproc.yaml ⠼[ERR] /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/mount.h:400:29: unexpected identifier __attribute, 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]

Maybe CC doesn't support __attribute function syntax?

from c-for-go.

xlab avatar xlab commented on July 17, 2024

I'm still using this config:

GENERATOR:
  PackageName: libproc
  PackageDescription: "Package vorbis provides Go bindings for OggVorbis implementation by the Xiph.Org Foundation"
  PackageLicense: "THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS."
  Includes: ["libproc.h"]
  Options:
    SafeStrings: true
PARSER:
  IncludePaths: ["/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/"]
  SourcesPaths: ["/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdks/MacOSX.sdk/usr/include/libproc.h"]
  
  Defines:


TRANSLATOR:
    MemTips:
      - {target: ^proc_$, self: raw}
    Rules: 
      global: 
        - {transform: lower}
        - {action: accept, from: "^proc_"}
        - {action: replace, from: "^proc_", to: _}
        - {transform: export}
      const:
        - {action: accept, from: "^PROC_"}
        - {action: replace, from: "^PROC_", to: _}
      type: 
        - {action: replace, from: "_t$"}
      private:
        - {transform: unexport}
      post-global:
        - {action: replace, from: _$}
        - {load: snakecase}

And getting nothing about Frameworks/Kernel.framework. Have you added some additional paths?

Btw, added support for __attribute, please update go get -u github.com/xlab/c-for-go

from c-for-go.

xlab avatar xlab commented on July 17, 2024

@tejasmanohar I also just fixed issue with _fd_def.h, you can uncomment that snippet back.

from c-for-go.

tejasmanohar avatar tejasmanohar commented on July 17, 2024

that worked thanks! i added "/System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/2.0/include/" instead of something in /Applications for stdbool.h now

from c-for-go.

xlab avatar xlab commented on July 17, 2024

Oh no, you could just create fake stdbool.h like this:

#ifndef STDBOOL_H
#define STDBOOL_H

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

#endif // STDBOOL_H

in the project's folder. No need to add extra deps

screen shot 2017-07-09 at 05 12 15

from c-for-go.

tejasmanohar avatar tejasmanohar commented on July 17, 2024

ah nice idea

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.