www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - UFC creating name conflict

reply Chris Piker <chris hoopjump.com> writes:
Hi D

I have and old C structure that I have to wrap that has a member 
named '.seconds', and in the module that handles this I also have 
conversion functions to go from an internal time representation 
to struct SysTime values.

Unfortunately importing `core.time` brings in a seconds function, 
which due to UFC is confused with a structure member of the same 
name.

How can I explicitly tell the compiler that I'm referring to:
```d

```
and not
```

```
?

Currently my code fails to compile due do this ambiguity.

Thanks for any advice you can give.  My google searches with the 
qualifier `site:dlang.org` weren't turning up any hits.
Oct 09 2021
parent reply Paul Backus <snarwin gmail.com> writes:
On Saturday, 9 October 2021 at 21:26:52 UTC, Chris Piker wrote:
 Unfortunately importing `core.time` brings in a seconds 
 function, which due to UFC is confused with a structure member 
 of the same name.

 How can I explicitly tell the compiler that I'm referring to:
 ```d

 ```
 and not
 ```

 ```
 ?

 Currently my code fails to compile due do this ambiguity.
A struct member always takes priority over a UFCS function, so there must be something else going on that you've left out of your explanation. Can you post a complete example that we can use to reproduce your issue?
Oct 09 2021
parent Chris Piker <chris hoopjump.com> writes:
On Saturday, 9 October 2021 at 21:37:27 UTC, Paul Backus wrote:
 On Saturday, 9 October 2021 at 21:26:52 UTC, Chris Piker wrote:
 A struct member always takes priority over a UFCS function, so 
 there must be something else going on that you've left out of 
 your explanation. Can you post a complete example that we can 
 use to reproduce your issue?
Ah. That's good to know, and comforting. Turns out this was an embarrassingly hasty post on my part. I was going by memory on the struct names and was just plain wrong. Struct member was `.second` not `.seconds`. The fact that I didn't get a "no member named seconds..." style error confused me for a bit. Problem solved. Thanks for the quick response,
Oct 09 2021