Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
October 31, 2014 Multiple declarations in a C++ namespace | ||||
---|---|---|---|---|
| ||||
I'm trying to bind to some C++ code, but when I compile the D side, there are errors. Here's my reduced test case:
// C++
namespace ns {
void func1();
void func2();
}
// D
module cpp;
extern(C++, ns) void func1();
extern(C++, ns) void func2()
dmd says:cpp_test.d(4): Error: namespace cpp.ns conflicts with namespace
cpp.ns at cpp_test.d(3)
What does this mean and how do I fix it?
Thanks!
--
Paul O'Neil
Github / IRC: todayman
|
October 31, 2014 Re: Multiple declarations in a C++ namespace | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul O'Neil | On Friday, 31 October 2014 at 02:01:00 UTC, Paul O'Neil wrote:
> I'm trying to bind to some C++ code, but when I compile the D side,
> there are errors. Here's my reduced test case:
>
> // C++
> namespace ns {
> void func1();
> void func2();
> }
>
> // D
> module cpp;
>
> extern(C++, ns) void func1();
> extern(C++, ns) void func2()
>
> dmd says:cpp_test.d(4): Error: namespace cpp.ns conflicts with namespace
> cpp.ns at cpp_test.d(3)
>
> What does this mean and how do I fix it?
>
> Thanks!
Did you try this?
extern(C++, ns)
{
void func1();
void func2();
}
The compiler probably thinks you're trying to declare two separate namespaces. I'm not sure if this is intended or not.
|
October 31, 2014 Re: Multiple declarations in a C++ namespace | ||||
---|---|---|---|---|
| ||||
Posted in reply to Meta | On 10/31/2014 12:55 AM, Meta wrote: > On Friday, 31 October 2014 at 02:01:00 UTC, Paul O'Neil wrote: >> I'm trying to bind to some C++ code, but when I compile the D side, there are errors. Here's my reduced test case: >> >> // C++ >> namespace ns { >> void func1(); >> void func2(); >> } >> >> // D >> module cpp; >> >> extern(C++, ns) void func1(); >> extern(C++, ns) void func2() >> >> dmd says:cpp_test.d(4): Error: namespace cpp.ns conflicts with namespace >> cpp.ns at cpp_test.d(3) >> >> What does this mean and how do I fix it? >> >> Thanks! > > Did you try this? > > extern(C++, ns) > { > void func1(); > void func2(); > } > > The compiler probably thinks you're trying to declare two separate namespaces. I'm not sure if this is intended or not. Thanks for the response. That does work. Should I file a bug report or create a PR for the docs? -- Paul O'Neil Github / IRC: todayman |
November 01, 2014 Re: Multiple declarations in a C++ namespace | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul O'Neil | On Friday, 31 October 2014 at 23:22:50 UTC, Paul O'Neil wrote:
> Thanks for the response. That does work.
>
> Should I file a bug report or create a PR for the docs?
It might be a good idea to create a thread in DigitalMars.D to get clarification on the intended behaviour. A doc PR never hurts either.
|
November 01, 2014 Re: Multiple declarations in a C++ namespace | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul O'Neil Attachments: | On Fri, 31 Oct 2014 19:23:06 -0400 "Paul O'Neil via Digitalmars-d-learn" <digitalmars-d-learn@puremagic.com> wrote: > Thanks for the response. That does work. > > Should I file a bug report or create a PR for the docs? i think it will be fine. and i think that this is more like a bug, 'cause it's ovbious that user wants the same namespace, not two identically named ones. |
Copyright © 1999-2021 by the D Language Foundation