Closed klmr closed 6 years ago
Thanks for the suggestion. What if we would call it from C++? Should we use something like this: https://github.com/ImageOptim/gifski/commit/555d3dc845b5b3b09180835958b594f7dd57123d
For a multi-purpose library, yes, the extern "C"
declaration would be necessary so that it can be called from C++ (but do note that extern "C"
is unrelated to plain extern
, confusingly).
But since this is a package-intern object .h
file, it will only ever be needed to compile the C wrapper for R, won’t it?
Right, we only have a C wrapper, but the purpose of this package is to provide a general template that people can use as a starting point if they want to wrap their own crates. So it should preferably generalize to people that wish to call rust from C++, without figuring out technical details.
Anyway I'm boarding a flight now, I'll have a look tonight. Thanks!
Fair point! I’ve added a commit to the PR.
extern
in C and C++ is used to syntactically distinguish declarations from definitions for the purpose of linkage. This isn’t necessary for function declarations: they always have external linkage (unless declaredstatic
or in an unnamed namespace).Since the rules are confusing, I suggest removing the redundant qualifier, as its presence here falsely suggests that it is necessary and confers semantic meaning.