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

Preprocessor macro with variadic args dropped without warning #257

Open
jblachly opened this issue Aug 14, 2020 · 3 comments
Open

Preprocessor macro with variadic args dropped without warning #257

jblachly opened this issue Aug 14, 2020 · 3 comments

Comments

@jblachly
Copy link

The following line:

#define sam_hdr_update_hd(h, ...) sam_hdr_update_line((h), "HD", NULL, NULL, __VA_ARGS__, NULL)

Is dropped silently without warning, I believe due to ... variadic arguments, or __VA_ARGS__ symbol.

No need to deal with variadic macros, but a warning is important so it can be added by hand.

Kind regards

@jacob-carlborg
Copy link
Owner

It seems the only problem is the variadic arguments, so hopefully it should be easy to fix.

@jblachly
Copy link
Author

Off-topic for dstep specifically but when I fixed this by hand it was my first experience with variadic templates in D and I was blown away by compile time sequences.

the fact that I could write

auto sam_hdr_update(T, A...)(T h, A a) {
    sam_hdr_update_line(h, "HD", null, null, a, ull);
}

and it just magically works calling the C variadic fn was really impressive. I even added a static assert to make sure the length of A was an even number at compile time.

@jacob-carlborg
Copy link
Owner

Yeah, it's pretty awesome.

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

No branches or pull requests

2 participants