Thread overview
Deprecated std.c.*.socket and missing replacement
Jun 27, 2017
Sebastiaan Koppe
Jun 27, 2017
Jonathan M Davis
Jun 27, 2017
Sebastiaan Koppe
Jun 27, 2017
Jonathan M Davis
Jun 27, 2017
Sebastiaan Koppe
Jun 27, 2017
Sebastiaan Koppe
June 27, 2017
I am building a multicast application, and I am using the std.c.*.socket modules to provide the definition of the IP_ADD_MEMBERSHIP constant.

These modules are marked as deprecated telling me to look in core.sys.posix.* instead.

I grepped the complete sourcetree, but nowhere is the IP_ADD_MEMBERSHIP constant defined other than in the deprecated modules.

What to do?
June 27, 2017
On Tuesday, June 27, 2017 10:48:12 Sebastiaan Koppe via Digitalmars-d-learn wrote:
> I am building a multicast application, and I am using the std.c.*.socket modules to provide the definition of the IP_ADD_MEMBERSHIP constant.
>
> These modules are marked as deprecated telling me to look in core.sys.posix.* instead.
>
> I grepped the complete sourcetree, but nowhere is the IP_ADD_MEMBERSHIP constant defined other than in the deprecated modules.
>
> What to do?

Create a PR to add it to druntime and/or define it in your own code.

- Jonathan M Davis

June 27, 2017
On Tuesday, 27 June 2017 at 11:16:17 UTC, Jonathan M Davis wrote:
> Create a PR to add it to druntime and/or define it in your own code.
>
> - Jonathan M Davis

Creating a PR sounds reasonable. But I would have to create one PR to remove them from phobos and one PR to add them to druntime, right? (I need to remove them since the phobos socket modules import the druntime ones, create duplicates if not removed)

I see that std.c.windows.winsock simply publicly imports core.sys.windows.winsock2, that looks like a good approach.
June 27, 2017
On Tuesday, June 27, 2017 3:46:39 PM MDT Sebastiaan Koppe via Digitalmars-d- learn wrote:
> On Tuesday, 27 June 2017 at 11:16:17 UTC, Jonathan M Davis wrote:
> > Create a PR to add it to druntime and/or define it in your own code.
> >
> > - Jonathan M Davis
>
> Creating a PR sounds reasonable. But I would have to create one PR to remove them from phobos and one PR to add them to druntime, right? (I need to remove them since the phobos socket modules import the druntime ones, create duplicates if not removed)
>
> I see that std.c.windows.winsock simply publicly imports core.sys.windows.winsock2, that looks like a good approach.

Why would you need to remove anything from Phobos? The enum in question is in a deprecated module. All that should need to happen is that the enum be added to the appropriate module in druntime, and then any code that uses it can import it from there.

- Jonathan M Davis

June 27, 2017
On Tuesday, 27 June 2017 at 17:58:29 UTC, Jonathan M Davis wrote:
> Why would you need to remove anything from Phobos? The enum in question is in a deprecated module. All that should need to happen is that the enum be added to the appropriate module in druntime, and then any code that uses it can import it from there.
>
> - Jonathan M Davis

Except that the deprecated module (std.c.posix.socket) imports the module where I would like to add them (core.sys.posix.netinet.in_), resulting in duplicated symbols. Therefor they need to be removed.

June 27, 2017
On 6/27/17 2:12 PM, Sebastiaan Koppe wrote:
> On Tuesday, 27 June 2017 at 17:58:29 UTC, Jonathan M Davis wrote:
>> Why would you need to remove anything from Phobos? The enum in question is in a deprecated module. All that should need to happen is that the enum be added to the appropriate module in druntime, and then any code that uses it can import it from there.
>>
>> - Jonathan M Davis
> 
> Except that the deprecated module (std.c.posix.socket) imports the module where I would like to add them (core.sys.posix.netinet.in_), resulting in duplicated symbols. Therefor they need to be removed.

Just delete the duplicate symbol, and add public imports of the other module symbols.

e.g.:

public import core.sys.posix.netinet.in_: IP_ADD_MEMBERSHIP;

-Steve
June 27, 2017
On Tuesday, 27 June 2017 at 19:22:02 UTC, Steven Schveighoffer wrote:
> Just delete the duplicate symbol, and add public imports of the other module symbols.
>
> e.g.:
>
> public import core.sys.posix.netinet.in_: IP_ADD_MEMBERSHIP;
>
> -Steve

Great. Will do.