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

[Help] Coolprop

Open mantielero opened this issue 5 years ago • 2 comments

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?

mantielero avatar Nov 28 '19 18:11 mantielero

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

xlab avatar Nov 29 '19 01:11 xlab

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?

mantielero avatar Nov 29 '19 23:11 mantielero