Skip to content

document filter syntax and usage #4981

Closed

Description

@Arlen22

Summary

The docs for windows-bindgen have no reference or explanation for what should go in the filter in order to accomplish any particular purpose.

Crate manifest

Crate code

Activity

  1. Arlen22 commented on Sep 22, 2026

    @Arlen22
    Author

    Yes, I don't know if I'm too new to rust and Windows apis or if it actually doesn't explain it. Apparently co-pilot is making sense of it and so far I think it's working but I basically just had to give it the VSS code example and just hope it would recognize the function names.

    Maybe that's the entire point. But it would be nice if there would be links to the standard Microsoft documentation for whatever it is generating.

    I really can't find any documentation for the filter argument. Maybe I just didn't look hard enough.

  2. riverar commented on Sep 22, 2026

    @riverar
    Collaborator

    Check out this section and let us know if it still doesn't make sense.

    Image
  3. Arlen22 commented on Sep 28, 2026

    @Arlen22
    Author

    I would say the docs are both incomplete and slightly misleading. In looking at this myself, I made an assumption which GPT-5.4 also made, twice. It was that the list of methods must be prefixed with some kind of windows prefixing, as shown. This however, did not actually work, and I don't know enough about windows to know if the list is wrong. What actually works is just removing everything before the :: from all of these and just specifying the function name itself.

    Windows.Win32.Storage.FileSystem::GetVolumeNameForVolumeMountPointW
    Windows.Win32.System.Com::CoInitializeEx
    Windows.Win32.System.Com::CoUninitialize
    Windows.Win32.System.Com::COINIT_MULTITHREADED
    Windows.Win32.Storage.Vss::CreateVssBackupComponentsInternal
    Windows.Win32.Storage.Vss::VSS_SNAPSHOT_PROP
    Windows.Win32.Storage.Vss::VssFreeSnapshotPropertiesInternal
    Windows.Win32.System.Memory::GetProcessHeap
    Windows.Win32.System.Memory::HeapCompact
    Windows.Win32.System.Threading::GetCurrentProcess
    Windows.Win32.System.Memory::SetProcessWorkingSetSize
    

    What worked much better was pasting this example file into the build.rs and then telling GPT-5.4 to work from there. Then it was fairly obvious what needed to happen. It first tried the namespaced list above, as specified in the docs, which didn't work, so it removed the prefix and just went with the sample. Honestly, after reading the docs, this was my initial assumption as well, which is why I used GPT because I had no idea where to find the windows namespace, but it clearly wouldn't have worked anyway.

    Since builder is referred to as a CLI-like reference, I think it would be useful to actually include the CLI-like help reference that should theoretically print if you called builder.help(). This means, at minimum, a list of each function call (at least the ones that are considered CLI-like arguments) with their doc comments, perhaps also specifying that .write() comes last. I think this should be added to windows-bindgen.md because otherwise it isn't clear at all how builder or bindgen are actually supposed to be invoked.

    The filter reference itself seems to be misleading GPT, and the entire understanding for how to use the builder required GPT to read the bindgen crate source code to determine the API shape, which seems a bit incomplete.

  4. LastExceed commented on Sep 30, 2026

    @LastExceed

    As per #4925 (comment) :
    The README section shown in Rafael Rivera (@riverar)'s screenshot is outdated. Namespaces have been removed from the Win32 bindings, and the only way to use them via windows-bindgen now is to specify every single required symbol individually.

    Judging by the subsequent comment, this seems to have been an intentional design decision, albeit one that has me stumped. It makes windows-bindgen practically unusable for anything beyond small scribbles, as maintaining a list of hundreds of symbols in build.rs gets infeasible pretty quickly. It is also inconsistent with the feature flags of the windows / windows-sys crates. Can we get some clarification on the rationale behind this?

  5. changed the title [-]Windows Bindgen docs missing filter reference[/-] [+]`windows-bindgen`: Document filter syntax and usage[/+] on Sep 30, 2026
  6. changed the title [-]`windows-bindgen`: Document filter syntax and usage[/-] [+]`windows-bindgen` document filter syntax and usage[/+] on Sep 30, 2026
  7. Arlen22 commented on Oct 1, 2026

    @Arlen22
    Author

    The README section shown in Rafael Rivera (@riverar)'s screenshot is outdated. Namespaces have been removed from the Win32 bindings, and the only way to use them via windows-bindgen now is to specify every single required symbol individually.

    Just to be clear, the screenshot is still current to the page at the moment, though the page the screenshot was taken of may be outdated.

  8. added
    windows-bindgen
    and removed on Oct 6, 2026
  9. changed the title [-]`windows-bindgen` document filter syntax and usage[/-] [+]document filter syntax and usage[/+] on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    windows-bindgen

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions