Bug 23757 – ImportC: fail to import malloc

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2023-03-03T19:39:02Z
Last change time
2023-05-31T08:27:09Z
Keywords
ImportC
Assigned to
No Owner
Creator
ryuukk_

Comments

Comment #0 by ryuukk.dev — 2023-03-03T19:39:02Z
DMD32 D Compiler v2.102.1 The following code: ``` import json; unittest { json_settings settings; settings.settings = json_enable_comments; char[256] error = 0; string a = "{ \"a\": 1 }"; json_value * value = json_parse_ex(&settings, a.ptr, a.length, error.ptr); } ``` Using c code: https://github.com/json-parser/json-parser Using developer command line prompt ``dmd -unittest -main -betterC -m64 -run package.d`` I get the following error: ``` C:\dev\kdom\better_d\rt\json>dmd -unittest -main -betterC -m64 -run package.d C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(58): Error: extended-decl-modifier expected C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(58): Error: no type for declarator before `)` C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(65): Error: extended-decl-modifier expected C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(65): Error: no type for declarator before `)` C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(94): Error: extended-decl-modifier expected C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(94): Error: no type for declarator before `)` C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(100): Error: extended-decl-modifier expected C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(100): Error: no type for declarator before `)` C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(118): Error: extended-decl-modifier expected C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(118): Error: no type for declarator before `)` C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(125): Error: extended-decl-modifier expected C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(125): Error: no type for declarator before `)` C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(132): Error: extended-decl-modifier expected C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(132): Error: no type for declarator before `)` C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(140): Error: extended-decl-modifier expected C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(140): Error: no type for declarator before `)` C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(153): Error: extended-decl-modifier expected C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(153): Error: no type for declarator before `)` C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(160): Error: extended-decl-modifier expected C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(160): Error: no type for declarator before `)` ```
Comment #1 by bugzilla — 2023-03-15T15:57:32Z
(In reply to ryuukk_ from comment #0) > Kits\10\include\10.0.19041.0\ucrt\corecrt_malloc.h(58): Error: > extended-decl-modifier expected I don't have this .h file. Please quote here the lines from it that cause the error.
Comment #2 by ryuukk.dev — 2023-03-15T19:24:20Z
As requested here is a copy of this file: https://gist.github.com/ryuukk/8ede8f2ec75085053e4861a0406d1e3f ``` _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Count * _Size) _ACRTIMP _CRTALLOCATOR _CRTRESTRICT void* __cdecl _calloc_base( _In_ size_t _Count, _In_ size_t _Size ); ``` ``` _Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Count * _Size) _ACRTIMP _CRT_JIT_INTRINSIC _CRTALLOCATOR _CRTRESTRICT _CRT_HYBRIDPATCHABLE void* __cdecl calloc( _In_ _CRT_GUARDOVERFLOW size_t _Count, _In_ _CRT_GUARDOVERFLOW size_t _Size ); ``` etc
Comment #3 by ryuukk.dev — 2023-03-15T22:02:37Z
This in case this is needed, here is what's installed in Visual Studio https://i.imgur.com/gNpLDiJ.png
Comment #4 by bugzilla — 2023-03-25T01:45:34Z
Is it possible you can post the code after the C preprocessor is through with it? I don't know what all those macros expand to.
Comment #5 by ryuukk.dev — 2023-03-25T05:32:21Z
I don't know how to do that, i am as blind as you, and to be honest, debugging throught this microsoft BS is not something i want to do
Comment #6 by ryuukk.dev — 2023-03-25T21:10:19Z
Apparently this is the fix: https://github.com/dlang/dmd/pull/15034
Comment #7 by bugzilla — 2023-05-31T08:27:09Z
(In reply to ryuukk_ from comment #6) > Apparently this is the fix: https://github.com/dlang/dmd/pull/15034 I'll take that as it's working now!