Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

struct _IO_FILE in generated .d file conflict with core.stdc.stdio._IO_FILE #272

Open
mw66 opened this issue Sep 6, 2020 · 5 comments
Open
Labels
bug workaround A workaround exists

Comments

@mw66
Copy link

mw66 commented Sep 6, 2020

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:

ldc-developers/ldc#2782 (comment)
)

@mw66
Copy link
Author

mw66 commented Sep 6, 2020

BTW, in Ubuntu, you can setup the ta-lib by:

	sudo apt install linuxbrew-wrapper
	brew install ta-lib

@atilaneves
Copy link
Owner

ldc doesn't like mangled names that are repeated. A workaround is to use dmd.

@atilaneves atilaneves added bug workaround A workaround exists labels Sep 8, 2020
@mw66
Copy link
Author

mw66 commented Sep 8, 2020

I've thought the problem is not about mangled names, but about:

%talib._IO_FILE*  v.s.
%core.stdc.stdio._IO_FILE*

and in ldc-developers/ldc#2782 (comment)

%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.

@mw66
Copy link
Author

mw66 commented Sep 13, 2020

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.

@Imperatorn
Copy link

Was this added?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug workaround A workaround exists
Projects
None yet
Development

No branches or pull requests

3 participants