Bug 24509 – importC cannot handle _stdcall Function Calling Convention with single heading underscore

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2024-04-16T12:57:22Z
Last change time
2024-04-23T14:24:17Z
Keywords
pull
Assigned to
No Owner
Creator
Ferhat Kurtulmuş

Comments

Comment #0 by aferust — 2024-04-16T12:57:22Z
In Windows programming, the stdcall calling convention is usually specified using the __stdcall keyword or macro. The import c documentation also lists __stdcall calling convention with double underscores. However, there are some occurrences in c library headers using single underscores. For instance, Microsoft's onnx runtime [1]. This kind of usage is not handled with importc. Importc yields a syntax error for these situations, such as: onnxruntime_c_api.h(288,25): Error: expected identifier for declarator onnxruntime_c_api.h(288,25): Error: `;` or `,` expected 1: https://github.com/microsoft/onnxruntime/blob/08d208b969fec6e7f6505f4f468eea0d6a9031c2/include/onnxruntime/core/session/onnxruntime_c_api.h#L86
Comment #1 by aferust — 2024-04-16T18:12:03Z
Comment #2 by aferust — 2024-04-16T21:45:55Z
My fix: https://github.com/aferust/dmd/commit/23e78aedb75931a27089ea1912d5fd56dd2d0c50 This is important because the MSVC compiler accepts both _stdcall and __stdcall, one or two underscores.
Comment #3 by aferust — 2024-04-17T08:35:58Z
Final fix after the reviews by the maintainers: https://github.com/dlang/dmd/pull/16392
Comment #4 by dlang-bot — 2024-04-18T10:26:50Z
@aferust updated dlang/dmd pull request #16392 "Fix bugzilla 24509: importC cannot handle _stdcall Function Calling …" fixing this issue: - Fix bugzilla 24509: importC cannot handle _stdcall Function Calling Convention with single heading underscore https://github.com/dlang/dmd/pull/16392
Comment #5 by dlang-bot — 2024-04-21T03:30:28Z
dlang/dmd pull request #16392 "Fix bugzilla 24509: importC cannot handle _stdcall Function Calling …" was merged into stable: - d07aa342e513a0a34a6ee6ab0e29ea6c14a9bb3c by aferust: Fix bugzilla 24509: importC cannot handle _stdcall Function Calling Convention with single heading underscore https://github.com/dlang/dmd/pull/16392
Comment #6 by dlang-bot — 2024-04-23T14:24:17Z
dlang/dmd pull request #16406 "Merge stable" was merged into master: - d61f72cbdc701aad056bd71f0dcef7795becf210 by Ferhat Kurtulmuş: Fix bugzilla 24509: importC cannot handle _stdcall Function Calling … (#16392) * Fix bugzilla 24509: importC cannot handle _stdcall Function Calling Convention with single heading underscore https://github.com/dlang/dmd/pull/16406