dpp
dpp copied to clipboard
struct _IO_FILE in generated .d file conflict with core.stdc.stdio._IO_FILE
Hi, I try to use
https://ta-lib.org/hdr_dw.html
http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
$ cat source/talib.dpp
#include "ta_libc.h"
~/.dub/packages/dpp-0.4.2/dpp/bin/d++ --preprocess-only --hard-fail --include-path=/home/linuxbrew/.linuxbrew/Cellar/ta-lib/0.4.0/include/ta-lib --keep-d-files --compiler=ldmd2 source/talib.dpp
The D compiler fails:
/project/ldc2-1.23.0-linux-x86_64/bin/../import/core/stdc/stdio.d(1317,8): Error: Function type does not match previously declared function with the same mangled name: fwrite
/project/ldc2-1.23.0-linux-x86_64/bin/../import/core/stdc/stdio.d(1317,8): Previous IR type: i64 (i8*, i64, i64, %talib._IO_FILE*)
/project/ldc2-1.23.0-linux-x86_64/bin/../import/core/stdc/stdio.d(1317,8): New IR type: i64 (i8*, i64, i64, %core.stdc.stdio._IO_FILE*)
I manually edited the generated source/talib.d, by adding at the top:
public import core.stdc.stdio;
and comment out:
/*
struct _IO_FILE { ... }
*/
Then it works.
I think this should be fixed by the dpp internally.
(BTW, I googled a bit, and found other people have this same problem too:
https://github.com/ldc-developers/ldc/issues/2782#issuecomment-495171179 )
BTW, in Ubuntu, you can setup the ta-lib by:
sudo apt install linuxbrew-wrapper
brew install ta-lib
ldc doesn't like mangled names that are repeated. A workaround is to use dmd.
I've thought the problem is not about mangled names, but about:
%talib._IO_FILE* v.s.
%core.stdc.stdio._IO_FILE*
and in https://github.com/ldc-developers/ldc/issues/2782#issuecomment-495171179
%libxlsxd.xlsxwrap._IO_FILE* v.s.
%core.stdc.stdio._IO_FILE*
i.e. the _IO_FILE become a symbol in the dpp file's package, instead of the standard: core.stdc.stdio._IO_FILE.
My manually modified generated file is here:
https://github.com/mingwugmail/talibd/blob/master/source/talib.d#L67
public import core.stdc.stdio;
...
version (DigitalMars) {
struct _IO_FILE
{...}
}
I think this is the only modification needed for it to work with LDC & DMD compilers, and struct _IO_FILE
is the only offending struct we experienced. Maybe this can be specially handled in dpp
so it will out out-of-box.
Thanks.
Was this added?