Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PInvoke007: The API "Windows.Win32.Foundation.PCSTR" is ambiguous #969

Closed
riverar opened this issue Jun 20, 2023 · 3 comments · Fixed by #974
Closed

PInvoke007: The API "Windows.Win32.Foundation.PCSTR" is ambiguous #969

riverar opened this issue Jun 20, 2023 · 3 comments · Fixed by #974
Assignees
Labels
bug Something isn't working

Comments

@riverar
Copy link

riverar commented Jun 20, 2023

Actual behavior

To workaround a previously reported issue, I copied/pasted CsWin32 generated output into a separate .cs and compiled it with my app. To resolve PCSTR references, I added Windows.Win32.Foundation.PCSTR to the NativeMethods.txt. This results in the confusing error below:

error PInvoke007: The API "Windows.Win32.Foundation.PCSTR" is ambiguous.
Please specify one of: "Windows.Win32.Foundation.PCSTR", "Windows.Win32.Foundation.PCSTR" or "Windows.Win32.Foundation.PCSTR".

Expected behavior

A clear error or no error at all.

Repro steps

TBD

Context

  • CsWin32 version: [e.g. 0.3.2-beta]
  • Win32Metadata version (if explicitly set by project):
  • Target Framework: [e.g. net6.0-windows10.0.17763.0]
  • LangVersion (if explicitly set by project): [e.g. 9]
@riverar riverar added the bug Something isn't working label Jun 20, 2023
@AArnott AArnott self-assigned this Jun 20, 2023
@AArnott
Copy link
Member

AArnott commented Jun 20, 2023

Oh dear. That's a terrible experience. It certainly is not supposed to do that.

@riverar
Copy link
Author

riverar commented Jun 20, 2023

Is this the expected way to bring in PCSTR? Was hesitant to file a bug as I wasn't sure if I was just doing something iffy.

@AArnott
Copy link
Member

AArnott commented Jun 20, 2023

Usually PCSTR will be brought in transitively. But if you own the only code that references it, you'll have to request it as you've done here. But PCSTR is a special type that doesn't appear in the metadata. That, and our recent support for multiple metadata files, may be why CsWin32 is misreporting an ambiguity. when you ask for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants