Bug 23935 – ImportC: __pragma not allowed between struct and tag name

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2023-05-24T16:38:22Z
Last change time
2023-05-30T16:01:26Z
Keywords
ImportC, pull
Assigned to
No Owner
Creator
a11e99z

Attachments

IDFilenameSummaryContent-TypeSize
1875uv9.i.zipproceeded uv9.iapplication/x-zip-compressed146459
1876uv9.i.zipcomressed uv9.i after fixing some issuesapplication/x-zip-compressed146077

Comments

Comment #0 by black80 — 2023-05-24T16:38:22Z
Created attachment 1875 proceeded uv9.i 1) I compiled uv.dll with vcpkg 2) I preprocessed "uv.h" (all libuv stuff) with command MSVC: cl.exe -P -Fiuv.i -DUSING_UV_SHARED -DWIN32_LEAN_AND_MEAN uv.h and got uv.i 3) I removed empty/#pragma/#line lines from the last one with commands: @findstr /v /r /c:"^[ \x09]*$" /c:"^$" uv.i >uv2.i @findstr /v /r /c:"^.*#line" uv2.i >uv3.i @findstr /v /r /c:"^.*#pragma warning" /c:"^.*#pragma once" /c:"^.*#pragma region" /c:"^.*#pragma endregion" uv3.i >uv9.i and got uv9.i ~1MB (in attachments) 4) dmd/ldc2 -c uv9.i gives to me many issues: uv9.i(2): Error: missing comma or semicolon after declaration of `__anonymous`, found `uintptr_t` instead ══uv9.i(4): Error: identifier or `(` expected Euv9.i(7): Error: missing comma or semicolon after declaration of `__anonymous`, found `size_t` instead rruv9.i(12): Error: identifier or `(` expected first 12LOC of uv9.i: #pragma pack(push, 8) typedef unsigned __int64 uintptr_t; typedef char* va_list; void __cdecl __va_start(va_list* , ...); #pragma pack(pop) __pragma(pack(push, 8)) typedef unsigned __int64 size_t; typedef __int64 ptrdiff_t; typedef __int64 intptr_t; typedef _Bool __vcrt_bool; typedef unsigned short wchar_t;
Comment #1 by black80 — 2023-05-24T17:05:50Z
so 1st simple step: dmd/importc can not eat unsigned __intXX: typedef unsigned __int64 uintptr_t; gives: Error: missing comma or semicolon after declaration of `__anonymous`, found `uintptr_t` instead
Comment #2 by black80 — 2023-05-24T17:29:59Z
Created attachment 1876 comressed uv9.i after fixing some issues preprocessed header with command: cl.exe -P -Fiuv.i -DUSING_UV_SHARED -DWIN32_LEAN_AND_MEAN -D__int64="long long" -D__int32="long" -D__cdecl="" -D__inline="inline" -D__forceinline="inline" -D__ptr64="" -D__ptr32="" -D__unaligned="" /std:c11 uv.h
Comment #3 by black80 — 2023-05-24T17:39:12Z
still fixing issues manually hint: '\' means code follows on next line w/o line break todo: ignore it in parser?
Comment #4 by black80 — 2023-05-24T17:57:02Z
fixed manually. not checked yet with calling libuv from D, but dmd gives uv9.obj. MSVC command: cl.exe -P -Fiuv.i -DUSING_UV_SHARED -DWIN32_LEAN_AND_MEAN -D__int64="long long" -D__int32="long" -D__cdecl="" -D__inline="inline" -D__forceinline="inline" -D__ptr64="" -D__ptr32="" -D__unaligned="" -D_CRT_SECURE_NO_WARNINGS /std:c11 uv.h and fixing is: 1) changed typedef struct __declspec(align(16)) __pragma(warning(push)) __pragma(warning(disable:4845)) __declspec(no_init_all) __pragma(warning(pop)) _CONTEXT { ... } CONTEXT, *PCONTEXT; with issues: uv9.i(4529): Error: missing tag `identifier` after `struct` uv9.i(4529): Error: identifier or `(` expected uv9.i(4598): Error: no type for declarator before `}` uv9.i(4598): Error: no type-specifier for declarator to: typedef struct /*__declspec(align(16)) __pragma(warning(push)) __pragma(warning(disable:4845)) __declspec(no_init_all) __pragma(warning(pop))*/ _CONTEXT { ... } CONTEXT __attribute__((aligned( 16))), *PCONTEXT; 2) removed '\' (no-line-break here) with issues: uv9.i(19384): Error: character '\' is not a valid token uv9.i(19385): Error: character '\' is not a valid token (2) should be fixed 100% (1) hmm, struct attrs should be reordered?
Comment #5 by dlang-bot — 2023-05-30T08:14:43Z
@WalterBright created dlang/dmd pull request #15279 "fix Issue 23935 - ImportC: __pragma not allowed between struct and ta…" fixing this issue: - fix Issue 23935 - ImportC: __pragma not allowed between struct and tag name https://github.com/dlang/dmd/pull/15279
Comment #6 by dlang-bot — 2023-05-30T16:01:26Z
dlang/dmd pull request #15279 "fix Issue 23935 - ImportC: __pragma not allowed between struct and ta…" was merged into master: - 8e9a91bd4c243892f39f80ec34fcc6927b59d0eb by Walter Bright: fix Issue 23935 - ImportC: __pragma not allowed between struct and tag name https://github.com/dlang/dmd/pull/15279