[GSoC] Header Generation for C/C++
Nicholas Wilson
iamthewilsonator at hotmail.com
Wed Jul 17 11:52:17 UTC 2019
On Wednesday, 17 July 2019 at 11:05:21 UTC, Eduard Staniloiu
wrote:
> On Tuesday, 16 July 2019 at 13:46:56 UTC, rikki cattermole
> wrote:
>> So currently there is no way to restrict it to just extern(C)?
>> I ask this because -HC makes me think C not C++ headers.
>
> Currently the outputted headers are C++ headers, but we were
> thinking of wrapping `extern (C++)` definitions inside an
> `#ifdef __cplusplus` block, and prefixing any `extern (C)`
> definitions with the following `EXTERNC` macro
>
> ```
> #ifdef __cplusplus
> #define EXTERNC extern(C)
> #else
> #define EXTERNC
> #endif
> ```
>
> This way, the generated header could be used in both C and C++.
>
> What do you think?
It should be pretty trivial to just check the linkage of the
symbols and only output extern(C) symbols.
Also you've clearly been doing too much D programming! (which is
probably a good thing) That would be:
#define EXTERNC extern "C" {
and you need to macro the closing brace as well.
More information about the Digitalmars-d
mailing list