xlab / c-for-go

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

[Help] Coolprop #82

Open mantielero opened 4 years ago

mantielero commented 4 years ago

I am trying to wrap CoolProp. I am a newbie in go, coolprop and c-for-go, so what can go wrong? ;oP

I am trying the following:

--- 
GENERATOR: 
  PackageName: coolprop
  PackageDescription: "Package nidaqmx provides Go bindings for CoolProp"
  PackageLicense: "THE AUTOGENERATED LICENSE. ALL THE RIGHTS ARE RESERVED BY ROBOTS."
  Includes: 
    - CoolProp.h

PARSER: 
  IncludePaths:
    - ../../include  
  SourcesPaths:
    - CoolPropLib.h

TRANSLATOR: 
  ConstRules: 
    defines: expand

  Rules: 
    global:   
      - {action:accept, from: "Props1SI"}

I am getting the following error:

[jose@mountain Golang]$ c-for-go coolprop-go.yml 
  processing coolprop-go.yml ⠋[ERR] ../../include/CoolPropLib.h:142:78: unexpected identifier val, 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]

so it complains about line 142.

Any idea about what am I doing wrong?

xlab commented 4 years ago

Hi! Try to define COOLPROP_LIB otherwise there will be no extern "C" in the headers.

https://github.com/xlab/c-for-go/wiki/Parser-config-section#defines

mantielero commented 4 years ago

With:

  Defines:    
    COOLPROP_LIB: 1

I get the error:

 processing coolprop-go.yml ⠋[ERR] ../../include/CoolPropLib.h:84:5: unexpected string literal "C", expected one of ['(', ')', '*', ',', ';', '[', _Bool, _Complex, _Noreturn, auto, char, const, double, enum, extern, float, identifier, inline, int, long, register, restrict, short, signed, static, struct, typedef, typedefname, typeof, union, unsigned, void, volatile]

So it fails here:

EXPORT_CODE double CONVENTION Props1SI(const char *FluidName, const char* Output);

I assume that EXPORT_CODE contains extern "C".

Any clue?