bytedeco / javacpp

The missing bridge between Java and native C++
Other
4.49k stars 583 forks source link

Builder fails to parse declaration prefix ## name #525

Closed luxingxiao closed 2 years ago

luxingxiao commented 2 years ago

When trying to package the liquid-dsp project (https://github.com/jgaeddert/liquid-dsp)

The actual error message:

Info: Parsing liquid.h Exception in thread "main" org.bytedeco.javacpp.tools.ParserException: liquid.h:325:"

define LIQUID_CONCAT(prefix, name) prefix ## name": Could not parse declaration at '##'

at org.bytedeco.javacpp.tools.Parser.declarations(Parser.java:4042)
at org.bytedeco.javacpp.tools.Parser.extern(Parser.java:3941)
at org.bytedeco.javacpp.tools.Parser.declarations(Parser.java:4035)
at org.bytedeco.javacpp.tools.Parser.parse(Parser.java:4125)
at org.bytedeco.javacpp.tools.Parser.parse(Parser.java:4266)
at org.bytedeco.javacpp.tools.Builder.parse(Builder.java:108)
at org.bytedeco.javacpp.tools.Builder.build(Builder.java:1103)
at org.bytedeco.javacpp.tools.Builder.main(Builder.java:1450)
saudet commented 2 years ago

Please try again with JavaCPP 1.5.6 and make sure to read this page: https://github.com/bytedeco/javacpp/wiki/Mapping-Recipes

luxingxiao commented 2 years ago

I have tried JavaCPP 1.5.6, but I still report this error. The following macro definition may not be supported:


#define LIQUID_CONCAT(prefix, name) prefix ## name

#define LIQUID_AGC_MANGLE_CRCF(name) LIQUID_CONCAT(agc_crcf, name)

#define LIQUID_AGC_DEFINE_API(AGC,T,TC)   \

AGC() AGC(_create)(void);                                  \

LIQUID_AGC_DEFINE_API(LIQUID_AGC_MANGLE_CRCF, float, liquid_float_complex)
saudet commented 2 years ago

I am going to need a little more context to answer this question. Could you show me all the code that you have?

luxingxiao commented 2 years ago

The InforMapper class:

@Properties(inherit = javacpp.class,
    target = "org.bytedeco.liquiddsp.global.liquid",
    value = {
        @Platform(include = "liquid.h", link = "liquid")
    })
@NoException
public class liquid implements InfoMapper {

  static {
    Loader.checkVersion("org.bytedeco", "liquid-dsp");
  }

  @Override
  public void map(InfoMap infoMap) {
    infoMap.put(new Info("HAVE_FFTW3_H && !defined LIQUID_FFTOVERRIDE").define(false));
  }

}

The attachment is the header file. liquid.h.zip

saudet commented 2 years ago

Ok, thank you! I found what the issue was. I've fixed this in commit https://github.com/bytedeco/javacpp/commit/ed47300434180434305ac79bb85872c188017357. Please give it a try with the snapshots: http://bytedeco.org/builds/

luxingxiao commented 2 years ago

Ok, thank you! I found what the issue was. I've fixed this in commit ed47300. Please give it a try with the snapshots: http://bytedeco.org/builds/

Great! It is working now!

saudet commented 2 years ago

The fix has been released with JavaCPP 1.5.7. Thanks for reporting!