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

macro functions not mapped to D #66

Open
timotheecour opened this issue Jan 10, 2018 · 0 comments
Open

macro functions not mapped to D #66

timotheecour opened this issue Jan 10, 2018 · 0 comments

Comments

@timotheecour
Copy link
Collaborator

timotheecour commented Jan 10, 2018

macros don't seemed to be mapped to D, despite what's said in https://wiki.dlang.org/Calypso: Constant and empty preprocessor macros (mapped to enums).

Other tools support macros (eg: swig, dstep etc)

test.h:

#define my_macro 42
#define my_macro2(x) (2*x)

main.d:

modmap (C++) "test.h";
import (C++) _;
void main(){
  enum a1=my_macro;  // Error: undefined identifier 'my_macro'
  enum a2=my_macro2(3);  // Error: undefined identifier 'my_macro2'
}

Use cases:
many (eg: CV_32F in opencv etc)

workaround:
add this in test.h:

enum class macros{
	_CV_8U=CV_8U,
	_CV_32F=CV_32F,
};

and in main.d:

import (C++) macros;
enum CV_8U=macros._CV_8U;

obviously, not ideal.

And for macro function, the workaround is more involved (define a template etc), and generates other issues: #67

EDIT: and this is despite:
Dsymbol* DeclMapper::VisitMacro(const clang::IdentifierInfo* II, const clang::Expr* E)
in ddmd/cpp/cppmodule.cpp

Syniurge added a commit that referenced this issue Jan 17, 2018
…, if their headers aren't part of a Clang module.
@timotheecour timotheecour changed the title macros not mapped to D macro functions not mapped to D Jan 18, 2018
Syniurge added a commit that referenced this issue Jan 20, 2018
…, if their headers aren't part of a Clang module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant