www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Deprecated std.c.*.socket and missing replacement

reply Sebastiaan Koppe <mail skoppe.eu> writes:
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?
Jun 27 2017
parent reply Jonathan M Davis via Digitalmars-d-learn writes:
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
Jun 27 2017
parent reply Sebastiaan Koppe <mail skoppe.eu> writes:
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.
Jun 27 2017
parent reply Jonathan M Davis via Digitalmars-d-learn writes:
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
Jun 27 2017
parent reply Sebastiaan Koppe <mail skoppe.eu> writes:
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.
Jun 27 2017
parent reply Steven Schveighoffer <schveiguy yahoo.com> writes:
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
Jun 27 2017
parent Sebastiaan Koppe <mail skoppe.eu> writes:
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.
Jun 27 2017