xlab / c-for-go

Automatic C-Go Bindings Generator for Go Programming Language
https://c.for-go.com
MIT License
1.47k stars 116 forks source link

unexpected identifier strtof32 #125

Closed abemedia closed 1 year ago

abemedia commented 2 years ago

When trying to build bindings for Python 3.9 I get the following error: processing python.yml ⠹[ERR] /usr/include/stdlib.h:140:17: unexpected identifier strtof32, 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]

This is the stdlib code causing the issue:

#if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
extern _Float32 strtof32 (const char *__restrict __nptr,
              char **__restrict __endptr)
     __THROW __nonnull ((1));
#endif

It seems both _Float32 and _Float64 don't exist in moderc.org/cc

This is my c-for-go config so far:

GENERATOR:
  PackageName: python
  PackageDescription: Package python provides Go bindings for Python.
  PackageLicense: THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS.
  PkgConfigOpts: [python3]
PARSER:
  SourcesPaths:
    - Python.h
xlab commented 2 years ago

I guess it will be broken in many other places too, but at least try to avoid this error by:

1) overriding __HAVE_FLOAT32 as 0 2) implementing strtof32 as a noop stub

abemedia commented 2 years ago

Stubs worked, however there's loads more issues. Since all these issues are in the standard library, do you know a version of it that works with c-for-go?