Skip to content

[UDFS] Convert C++ to C for MinGW compatibility and apply chunked bitmap refactor#105

Closed
Copilot wants to merge 13 commits into
writefrom
copilot/convert-cpp-to-c
Closed

[UDFS] Convert C++ to C for MinGW compatibility and apply chunked bitmap refactor#105
Copilot wants to merge 13 commits into
writefrom
copilot/convert-cpp-to-c

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 6, 2026

  • Convert using type aliases in struct.h to typedef declarations
  • Replace static_assert with C_ASSERT in struct.h
  • Add typedef forward declarations for struct types used without struct keyword in struct.h
  • Remove extern "C" from protos.h
  • Remove extern "C" from Include/string_lib.c
  • Rename all .cpp files to .c files (41 files total)
  • Update CMakeLists.txt to reference .c files and remove C++ specific flags
  • Update #include directives to reference .c files
  • Add typedef struct FCB FCB in udf_info/udf_rel.h
  • Add typedef aliases for all struct types in udf_info/ecma_167.h
  • Add typedef aliases for all struct types in udf_info/osta_misc.h
  • Fix empty structs FCB_DATA and FCB_INDEX in struct.h
  • Add typedefs for FCB_DATA, FCB_INDEX, UDFFSD_MEDIA_TYPE, VCB_CONDITION in struct.h
  • Fix udf_dbg.h: Change PCH Format to PCSTR Format in DbgPrint declaration; replace {NOTHING;} macros with ((void)0)
  • Fix udf_info/udf_info.h: Remove C++ default param = FLUSH_FE_KEEP from UDFFlushFESpace
  • Fix udf_info/udf_info.h: Remove C++ default param = 0 from UDFFlushFile__
  • Fix protos.h: Remove C++ default params from UDFFlushAFile, UDFFlushADirectory, UDFFlushVolume, UDFFlushIsBreaking, UDFGetRegParameter; add declarations for new chunked bitmap functions
  • Fix protos.h: Add typedef enum TYPE_OF_ACQUIRE TYPE_OF_ACQUIRE;
  • Fix Include/phys_lib.h: Remove C++ default param = 0 from UDFTRead, UDFTWrite
  • Update callers that relied on default values to pass explicit values
  • Fix udf_info/mount.c(2738): Replace relPrevExt, prevExt = NULL; with relPrevExt = prevExt = 0;
  • Fix udf_info/udf_info.h: Correct PLONG_ADPSHORT_AD in UDFShortAllocDescToMapping and PLONG_ADPEXT_AD in UDFExtAllocDescToMapping
  • Fix Include/phys_lib.c: Replace 0,NULL with NULL,0 in UDFPhSendIOCTL calls (param 3=PVOID, param 4=ULONG)
  • Fix udf_info/udf_info.c(4390): Replace return NULL with return STATUS_UNSUCCESSFUL in UDFReadTagged
  • Fix fscntrl.c(299): Replace auto RealDevice = Vpb->RealDevice with PDEVICE_OBJECT RealDevice = Vpb->RealDevice
  • Fix misc.c(714): Replace C++ false with WDK FALSE; replace KeAreAllApcsDisabled() with KeGetCurrentIrql() >= APC_LEVEL
  • Fix strucsup.c(910): Replace C++ value-initialization FILE_ID FileId{} with FILE_ID FileId = {0}
  • Fix strucsup.c(1099): Replace C++ struct assignment with RtlInitUnicodeString
  • Fix write.c(256): Add missing Flags=0 argument to UDFTWrite call
  • Add UDF_BITMAP_CHUNK and UDF_CHUNKED_BITMAP type definitions to struct.h; replace flat FSBM_Bitmap/BSBM_Bitmap/FSBM_OldBitmap pointers in VCB with UDF_CHUNKED_BITMAP structs and add FSBM_LockDepth
  • Add full chunked/RLE bitmap implementation to udf_info/alloc.c (UDFInitChunkedBitmap, UDFFreeChunkedBitmap, UDFChunkedGetBit/SetBit/ClrBit/SetBits/ClrBits/GetBitmapLen/CountFreeBits, compress/decompress functions); update all bitmap access sites
  • Update udf_info/mount.c, udf_info/extent.c, udf_info/dirtree.c, fscntrl.c to use chunked bitmap API; add UDFDecompressBitmaps/UDFCompressBitmaps calls around exclusive bitmap locks
  • Fix read.c/write.c: Add FcbPagingIoResource acquisition for paging I/O to prevent deadlocks; fix Wait = trueWait = TRUE
  • Fix create.c: Remove redundant UDFIsADirectory check for embedded-data flag
  • Fix Include/mem_tools.c: Replace {NOTHING;} macros with ((void)0)
  • Update udf_info/udf_info.h and udffs.h with declarations for new chunked bitmap functions
Original prompt

This section details on the original issue you should resolve

<issue_title>[UDFS] Convert C++ to C so it can compile under MinGW based build environments without warnings</issue_title>
<issue_description>[UDFS] Convert C++ to C so it can compile under MinGW based build environments without warnings</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Rename all .cpp files to .c in the driver, udf_info, and Include directories
- Update CMakeLists.txt to reference .c files and remove C++ specific flags
- Convert C++ `using` type aliases to `typedef` in struct.h
- Replace `static_assert` with `C_ASSERT` in struct.h
- Add typedef forward declarations for struct types in struct.h
- Remove `extern "C"` from protos.h and Include/string_lib.c
- Update #include directives for renamed .c files
- Update file header comments to reference .c filenames

Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Copilot AI changed the title [WIP] Convert C++ code to C for MinGW compatibility [UDFS] Convert C++ to C for MinGW compatibility Mar 6, 2026
@Zero3K20
Copy link
Copy Markdown
Owner

Zero3K20 commented Mar 6, 2026

@copilot

D:\reactos\drivers\filesystems\udfs\udf_info/udf_rel.h(249): error C2061: syntax
 error: identifier 'FCB'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_rel.h(314): error C2059: syntax
 error: '}'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_rel.h(361): error C2061: syntax
 error: identifier 'PUDF_DATALOC_INFO'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_rel.h(406): error C2059: syntax
 error: '}'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_rel.h(409): error C2061: syntax
 error: identifier 'PUDF_FILE_INFO'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_rel.h(411): error C2059: syntax
 error: '}'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_rel.h(431): error C2061: syntax
 error: identifier 'PUDF_DATALOC_INFO'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_rel.h(432): error C2059: syntax
 error: '}'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_rel.h(435): error C2061: syntax
 error: identifier 'PUDF_FILE_INFO'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_rel.h(442): error C2059: syntax
 error: '}'
D:\reactos\drivers\filesystems\udfs\struct.h(204): error C2016: C requires that
a struct or union have at least one member
D:\reactos\drivers\filesystems\udfs\struct.h(208): error C2016: C requires that
a struct or union have at least one member
D:\reactos\drivers\filesystems\udfs\struct.h(222): error C2061: syntax error: id
entifier 'PUDF_FILE_INFO'
D:\reactos\drivers\filesystems\udfs\struct.h(290): error C2061: syntax error: id
entifier 'FCB_DATA'
D:\reactos\drivers\filesystems\udfs\struct.h(291): error C2061: syntax error: id
entifier 'FcbIndex'
D:\reactos\drivers\filesystems\udfs\struct.h(291): error C2059: syntax error: ';
'
D:\reactos\drivers\filesystems\udfs\struct.h(292): error C2059: syntax error: '}
'
D:\reactos\drivers\filesystems\udfs\struct.h(293): error C2059: syntax error: '}
'
D:\reactos\drivers\filesystems\udfs\struct.h(361): error C2061: syntax error: id
entifier 'VCB_CONDITION'
D:\reactos\drivers\filesystems\udfs\struct.h(377): warning C4094: untagged 'unio
n' declared no symbols
D:\reactos\drivers\filesystems\udfs\struct.h(517): error C2143: syntax error: mi
ssing '{' before '*'
D:\reactos\drivers\filesystems\udfs\struct.h(535): error C2061: syntax error: id
entifier 'VatFileInfo'
D:\reactos\drivers\filesystems\udfs\struct.h(535): error C2059: syntax error: ';
'
D:\reactos\drivers\filesystems\udfs\struct.h(570): error C2061: syntax error: id
entifier 'SysSDirFileInfo'
D:\reactos\drivers\filesystems\udfs\struct.h(570): error C2059: syntax error: ';
'
D:\reactos\drivers\filesystems\udfs\struct.h(572): error C2061: syntax error: id
entifier 'NonAllocFileInfo'
D:\reactos\drivers\filesystems\udfs\struct.h(572): error C2059: syntax error: ';
'
D:\reactos\drivers\filesystems\udfs\struct.h(574): error C2061: syntax error: id
entifier 'UniqueIDMapFileInfo'
D:\reactos\drivers\filesystems\udfs\struct.h(574): error C2059: syntax error: ';
'
D:\reactos\drivers\filesystems\udfs\struct.h(583): error C2061: syntax error: id
entifier 'DlocList'
D:\reactos\drivers\filesystems\udfs\struct.h(583): error C2059: syntax error: ';
'
D:\reactos\drivers\filesystems\udfs\struct.h(588): error C2061: syntax error: id
entifier 'MediaTypeEx'
D:\reactos\drivers\filesystems\udfs\struct.h(588): error C2059: syntax error: ';
'
D:\reactos\drivers\filesystems\udfs\struct.h(616): error C2059: syntax error: '}
'
D:\reactos\drivers\filesystems\udfs\struct.h(668): error C2079: 'Vcb' uses undef
ined struct 'VCB'
D:\reactos\drivers\filesystems\udfs\udf_dbg.h(54): warning C4028: formal paramet
er 1 different from declaration
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(50): error C2146: syn
tax error: missing ')' before identifier 'FileInfo'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(50): error C2061: syn
tax error: identifier 'FileInfo'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(50): error C2059: syn
tax error: ';'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(50): error C2059: syn
tax error: ','
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(54): error C2059: syn
tax error: ')'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(56): error C2146: syn
tax error: missing ')' before identifier 'FileInfo'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(56): error C2061: syn
tax error: identifier 'FileInfo'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(56): error C2059: syn
tax error: ';'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(56): error C2059: syn
tax error: ','
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(60): error C2059: syn
tax error: ')'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(146): error C2146: sy
ntax error: missing ')' before identifier 'DirInfo'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(146): error C2081: 'P
UDF_FILE_INFO': name in formal parameter list illegal
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(146): error C2061: sy
ntax error: identifier 'DirInfo'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(146): error C2059: sy
ntax error: ';'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(146): error C2059: sy
ntax error: ')'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(162): error C2146: sy
ntax error: missing ')' before identifier 'FileInfo'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(162): error C2061: sy
ntax error: identifier 'FileInfo'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(162): error C2059: sy
ntax error: ';'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(162): error C2059: sy
ntax error: ')'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(164): error C2146: sy
ntax error: missing ')' before identifier 'FileInfo'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(164): error C2061: sy
ntax error: identifier 'FileInfo'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(164): error C2059: sy
ntax error: ';'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(164): error C2059: sy
ntax error: ')'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(166): error C2146: sy
ntax error: missing ')' before identifier 'FileInfo'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(166): error C2061: sy
ntax error: identifier 'FileInfo'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(166): error C2059: sy
ntax error: ';'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(166): error C2059: sy
ntax error: ')'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(167): error C2146: sy
ntax error: missing ')' before identifier 'FileInfo'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(167): error C2061: sy
ntax error: identifier 'FileInfo'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(167): error C2059: sy
ntax error: ';'
D:\reactos\drivers\filesystems\udfs\Include/Sys_spec_lib.h(167): error C2059: sy
ntax error: ')'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(99): error C2146: syntax
 error: missing ')' before identifier 'DirInfo'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(99): error C2061: syntax
 error: identifier 'DirInfo'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(99): error C2059: syntax
 error: ';'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(99): error C2059: syntax
 error: ','
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(101): error C2059: synta
x error: ')'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(103): error C2146: synta
x error: missing ')' before identifier 'Context'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(103): error C2061: synta
x error: identifier 'Context'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(103): error C2059: synta
x error: ';'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(103): error C2059: synta
x error: ','
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(104): error C2059: synta
x error: ')'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(111): error C2146: synta
x error: missing ')' before identifier 'FileInfo'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(111): error C2081: 'PUDF
_FILE_INFO': name in formal parameter list illegal
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(111): error C2061: synta
x error: identifier 'FileInfo'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(111): error C2059: synta
x error: ';'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(112): error C2059: synta
x error: ')'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(120): error C2146: synta
x error: missing ')' before identifier 'DirInfo'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(120): error C2081: 'PUDF
_FILE_INFO': name in formal parameter list illegal
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(120): error C2061: synta
x error: identifier 'DirInfo'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(120): error C2059: synta
x error: ';'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(120): error C2059: synta
x error: ','
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(121): error C2059: synta
x error: ')'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(126): error C2146: synta
x error: missing ')' before identifier 'DirInfo'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(126): error C2081: 'PUDF
_FILE_INFO': name in formal parameter list illegal
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(126): error C2061: synta
x error: identifier 'DirInfo'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(126): error C2059: synta
x error: ';'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(126): error C2059: synta
x error: ')'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(127): error C2449: found
 '{' at file scope (missing function header?)
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(132): error C2059: synta
x error: '}'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(430): error C2146: synta
x error: missing ')' before identifier 'DirInfo'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(430): error C2081: 'PUDF
_FILE_INFO': name in formal parameter list illegal
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(430): error C2061: synta
x error: identifier 'DirInfo'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(430): error C2059: synta
x error: ';'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(430): error C2059: synta
x error: ','
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(434): error C2059: synta
x error: ')'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(438): error C2146: synta
x error: missing ')' before identifier 'DirInfo'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(438): error C2081: 'PUDF
_FILE_INFO': name in formal parameter list illegal
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(438): fatal error C1003:
 error count exceeds 100; stopping compilation
ninja: build stopped: subcommand failed.

- Add typedef struct FCB FCB in udf_rel.h to allow FCB* usage without struct prefix
- Add typedef aliases in ecma_167.h for all struct types used without struct prefix
- Add typedef aliases in osta_misc.h for all struct types used without struct prefix
- Fix empty structs FCB_DATA and FCB_INDEX in struct.h (C requires at least one member)
- Add typedef FCB_DATA, FCB_INDEX, UDFFSD_MEDIA_TYPE, VCB_CONDITION in struct.h

Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Mar 6, 2026

@copilot

...

Fixed in e8ae549. The errors cascaded from a single root cause: udf_rel.h used FCB* without the struct keyword but had no typedef struct FCB FCB. This caused all the PUDF_FILE_INFO/PUDF_DATALOC_INFO definitions to fail to parse, which in turn broke struct.h, Sys_spec_lib.h, and udf_info.h.

Additional fixes:

  • Added typedef aliases at the end of ecma_167.h and osta_misc.h for all struct types used without the struct prefix (e.g. PartitionDesc, LogicalVolDesc, FidADImpUse, VirtualAllocationTable15/20, etc.)
  • Added typedefs for FCB_DATA, FCB_INDEX, UDFFSD_MEDIA_TYPE, and VCB_CONDITION in struct.h
  • Fixed empty structs FCB_DATA and FCB_INDEX (C requires at least one member)

@Zero3K20
Copy link
Copy Markdown
Owner

Zero3K20 commented Mar 6, 2026

@copilot

D:\reactos\drivers\filesystems\udfs\udf_dbg.h(54): error C2220: the following wa
rning is treated as an error
D:\reactos\drivers\filesystems\udfs\udf_dbg.h(54): warning C4028: formal paramet
er 1 different from declaration
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(447): error C2143: synta
x error: missing ')' before '='
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(447): error C2072: 'UDFF
lushFESpace': initialization of a function
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(447): error C2059: synta
x error: ')'
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(1025): error C2143: synt
ax error: missing ')' before '='
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(1025): error C2072: 'UDF
FlushFile__': initialization of a function
D:\reactos\drivers\filesystems\udfs\udf_info/udf_info.h(1026): error C2059: synt
ax error: ')'
D:\reactos\drivers\filesystems\udfs\protos.h(534): error C2143: syntax error: mi
ssing ')' before '='
D:\reactos\drivers\filesystems\udfs\protos.h(534): error C2072: 'UDFFlushAFile':
 initialization of a function
D:\reactos\drivers\filesystems\udfs\protos.h(535): error C2059: syntax error: ')
'
D:\reactos\drivers\filesystems\udfs\protos.h(543): error C2143: syntax error: mi
ssing ')' before '='
D:\reactos\drivers\filesystems\udfs\protos.h(543): error C2072: 'UDFFlushADirect
ory': initialization of a function
D:\reactos\drivers\filesystems\udfs\protos.h(544): error C2059: syntax error: ')
'
D:\reactos\drivers\filesystems\udfs\protos.h(550): error C2143: syntax error: mi
ssing ')' before '='
D:\reactos\drivers\filesystems\udfs\protos.h(550): error C2072: 'UDFFlushVolume'
: initialization of a function
D:\reactos\drivers\filesystems\udfs\protos.h(551): error C2059: syntax error: ')
'
D:\reactos\drivers\filesystems\udfs\protos.h(560): error C2143: syntax error: mi
ssing ')' before '='
D:\reactos\drivers\filesystems\udfs\protos.h(560): error C2072: 'UDFFlushIsBreak
ing': initialization of a function
D:\reactos\drivers\filesystems\udfs\protos.h(560): error C2059: syntax error: ')
'
D:\reactos\drivers\filesystems\udfs\protos.h(845): error C2143: syntax error: mi
ssing ')' before '='
D:\reactos\drivers\filesystems\udfs\protos.h(845): error C2072: 'UDFGetRegParame
ter': initialization of a function
D:\reactos\drivers\filesystems\udfs\protos.h(845): error C2059: syntax error: ')
'
D:\reactos\drivers\filesystems\udfs\protos.h(1238): error C2146: syntax error: m
issing ')' before identifier 'Type'
D:\reactos\drivers\filesystems\udfs\protos.h(1238): error C2081: 'TYPE_OF_ACQUIR
E': name in formal parameter list illegal
D:\reactos\drivers\filesystems\udfs\protos.h(1238): error C2061: syntax error: i
dentifier 'Type'
D:\reactos\drivers\filesystems\udfs\protos.h(1238): error C2059: syntax error: '
;'
D:\reactos\drivers\filesystems\udfs\protos.h(1239): error C2059: syntax error: '
)'
D:\reactos\drivers\filesystems\udfs\Include/phys_lib.h(18): error C2143: syntax
error: missing ')' before '='
D:\reactos\drivers\filesystems\udfs\Include/phys_lib.h(18): error C2072: 'UDFTRe
ad': initialization of a function
D:\reactos\drivers\filesystems\udfs\Include/phys_lib.h(19): error C2059: syntax
error: ')'
D:\reactos\drivers\filesystems\udfs\Include/phys_lib.h(29): error C2143: syntax
error: missing ')' before '='
D:\reactos\drivers\filesystems\udfs\Include/phys_lib.h(29): error C2072: 'UDFTWr
ite': initialization of a function
D:\reactos\drivers\filesystems\udfs\Include/phys_lib.h(30): error C2059: syntax
error: ')'

- Remove C++ default parameter values from UDFFlushFESpace, UDFFlushFile__,
  UDFFlushAFile, UDFFlushADirectory, UDFFlushVolume, UDFFlushIsBreaking,
  UDFGetRegParameter (protos.h/udf_info.h), UDFTRead/UDFTWrite (phys_lib.h)
- Update all callers that relied on default values to pass explicit args:
  cleanup.c, create.c, close.c, mount.c, udf_info.c, fscntrl.c, shutdown.c,
  flush.c, write.c, phys_eject.c, phys_lib.c
- Add typedef enum TYPE_OF_ACQUIRE in protos.h
- Fix udf_dbg.h DbgPrint: PCH -> PCSTR to match system header signature

Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Mar 6, 2026

@copilot

...

Fixed in bedb7bd. These errors came from two C++ features not supported in C:

  1. Default parameter values — Removed = 0 / = FLUSH_FE_KEEP from all function declarations in protos.h, udf_info/udf_info.h, and Include/phys_lib.h. Updated all callers that relied on the defaults to pass explicit values.

  2. DbgPrint parameter mismatch — Changed PCH Format to PCSTR Format in udf_dbg.h to match the system header's signature (treating the warning as an error).

  3. TYPE_OF_ACQUIRE enum without typedef — Added typedef enum TYPE_OF_ACQUIRE TYPE_OF_ACQUIRE; in protos.h so the type can be used without the enum prefix in C.

@Zero3K20
Copy link
Copy Markdown
Owner

Zero3K20 commented Mar 6, 2026

@copilot

..\drivers\filesystems\udfs\udf_info\mount.c(2738): error C2220: the following w
arning is treated as an error
..\drivers\filesystems\udfs\udf_info\mount.c(2738): warning C4047: '=': 'uint32'
 differs in levels of indirection from 'void *'
ninja: build stopped: subcommand failed.

…ization

`relPrevExt, prevExt = NULL;` caused C4047 (pointer/integer mismatch)
in C mode since NULL expands to (void*)0. Changed to `relPrevExt = prevExt = 0;`.

Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Mar 6, 2026

@copilot

...

Fixed in a9cc81d. relPrevExt, prevExt = NULL; used the C++ comma-as-expression trick where assigning NULL (defined as 0 in C++) to a uint32 was fine. In C mode, NULL expands to (void*)0, causing the C4047 indirection mismatch. Changed to relPrevExt = prevExt = 0;.

@Zero3K20
Copy link
Copy Markdown
Owner

Zero3K20 commented Mar 6, 2026

@copilot

..\drivers\filesystems\udfs\udf_info\extent.c(265): error C2220: the following w
arning is treated as an error
..\drivers\filesystems\udfs\udf_info\extent.c(265): warning C4028: formal parame
ter 4 different from declaration
..\drivers\filesystems\udfs\udf_info\extent.c(597): warning C4028: formal parame
ter 3 different from declaration
[6/39] Building C object drivers\files...akeFiles\udfs.dir\udf_info\mount.c.obj
ninja: build stopped: subcommand failed.

… and UDFExtAllocDescToMapping

Both declarations used PLONG_AD but definitions use PSHORT_AD and PEXT_AD
respectively, causing C4028 (formal parameter different from declaration)
treated as error in C mode.

Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Mar 6, 2026

@copilot

...

Fixed in 94e7855. Both declarations in udf_info.h incorrectly used PLONG_AD as the array parameter type — UDFShortAllocDescToMapping should take PSHORT_AD (parameter 4) and UDFExtAllocDescToMapping should take PEXT_AD (parameter 3), matching their actual definitions in extent.c.

@Zero3K20
Copy link
Copy Markdown
Owner

Zero3K20 commented Mar 6, 2026

@copilot

D:\reactos\drivers\filesystems\udfs\Include/phys_lib.c(799): error C2220: the fo
llowing warning is treated as an error
D:\reactos\drivers\filesystems\udfs\Include/phys_lib.c(799): warning C4047: 'fun
ction': 'ULONG' differs in levels of indirection from 'void *'
D:\reactos\drivers\filesystems\udfs\Include/phys_lib.c(799): warning C4024: 'UDF
PhSendIOCTL': different types for formal and actual parameter 4
D:\reactos\drivers\filesystems\udfs\Include/phys_lib.c(806): warning C4047: 'fun
ction': 'ULONG' differs in levels of indirection from 'void *'
D:\reactos\drivers\filesystems\udfs\Include/phys_lib.c(806): warning C4024: 'UDF
PhSendIOCTL': different types for formal and actual parameter 4

In C mode NULL expands to (void*)0, causing C4047 when passed for
ULONG InputBufferLength (param 4). Swap to NULL (PVOID) and 0 (ULONG)
to match the function signature.

Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
…OBJECT

'auto RealDevice = Vpb->RealDevice' used C++11 type deduction.
In C, 'auto' is the old storage class specifier making the variable
default to 'int', causing cascading C2223/C4047/C2198 errors
on all uses of RealDevice (->Flags, ->DeviceType, UDFPhSendIOCTL
calls, IoCreateStreamFileObject).

Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Mar 6, 2026

@copilot

...

Fixed in 4cc3b1b. All errors cascaded from auto RealDevice = Vpb->RealDevice; on line 299 — C++11 type deduction. In C, auto is the old storage-class specifier and the variable defaults to int, causing C2223 on ->Flags/->DeviceType, C4047 on the UDFPhSendIOCTL calls, and C4047 on IoCreateStreamFileObject. Changed to PDEVICE_OBJECT RealDevice = Vpb->RealDevice;.

@Zero3K20
Copy link
Copy Markdown
Owner

Zero3K20 commented Mar 6, 2026

@copilot

es\udfs.dir\ /FS -c ..\drivers\filesystems\udfs\misc.c
..\drivers\filesystems\udfs\misc.c(714): error C2065: 'false': undeclared identi
fier
[24/39] Building C object drivers\file...udfs\CMakeFiles\udfs.dir\namesup.c.obj
ninja: build stopped: subcommand failed.

In C, 'false' is not a keyword (it's defined in <stdbool.h>).
Replace with the WDK 'FALSE' macro already available in the codebase.

Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Mar 6, 2026

@copilot

...

Fixed in 3b457e7. false is a C++ built-in keyword; in C it's not defined without <stdbool.h>. Replaced with the WDK FALSE macro that's already universally available in this codebase.

@Zero3K20
Copy link
Copy Markdown
Owner

Zero3K20 commented Mar 6, 2026

@copilot

eFiles\udfs.dir\ /FS -c ..\drivers\filesystems\udfs\strucsup.c
..\drivers\filesystems\udfs\strucsup.c(910): error C2143: syntax error: missing
';' before '{'
..\drivers\filesystems\udfs\strucsup.c(1099): error C2059: syntax error: '{'
ninja: build stopped: subcommand failed.

- Line 910: FILE_ID FileId{} → FILE_ID FileId = {0}
- Line 1099: LocalPath = RTL_CONSTANT_STRING(...) → RtlInitUnicodeString()

Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Mar 6, 2026

@copilot

...

Fixed in caf1e05. Two C++ constructs in strucsup.c:

  • Line 910: FILE_ID FileId{} (C++ value-initialization) → FILE_ID FileId = {0}
  • Line 1099: LocalPath = RTL_CONSTANT_STRING(...) (C++ braced-init assignment, not valid in MSVC C mode) → RtlInitUnicodeString(&LocalPath, UDF_SN_UID_MAPPING)

@Zero3K20
Copy link
Copy Markdown
Owner

Zero3K20 commented Mar 6, 2026

@copilot

..\drivers\filesystems\udfs\write.c(256): error C2198: 'UDFTWrite': too few argu
ments for call
[37/40] Building C object drivers\file...dfs\CMakeFiles\udfs.dir\strucsup.c.obj

Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Mar 6, 2026

@copilot

..\drivers\filesystems\udfs\write.c(256): error C2198: 'UDFTWrite': too few argu

...

Fixed in ec42c8d. The UDFTWrite call in write.c(256) was missing the Flags argument after the default parameter was removed. Added 0 as the explicit Flags value.

@Zero3K20
Copy link
Copy Markdown
Owner

Zero3K20 commented Mar 6, 2026

@copilot Please make a version of https://patch-diff.githubusercontent.com/raw/Zero3K20/reactos/pull/79.diff that can apply to this PR with no errors.

Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Mar 6, 2026

@copilot Please make a version of https://patch-diff.githubusercontent.com/raw/Zero3K20/reactos/pull/79.diff that can apply to this PR with no errors.

Applied in 2480da1. The original 79.diff failed on struct.h because our PR had already added typedef enum VCB_CONDITION VCB_CONDITION; after the enum, shifting the context. I applied the diff using --3way with all .cpp.c path substitutions, then fixed the two Wait = true; instances PR #79 introduced (changed to Wait = TRUE; for C compatibility). All 17 files patched cleanly.

Copilot AI changed the title [UDFS] Convert C++ to C for MinGW compatibility [UDFS] Convert C++ to C for MinGW compatibility and apply chunked bitmap refactor Mar 6, 2026
Copilot AI added a commit that referenced this pull request Mar 6, 2026
Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
@Zero3K20 Zero3K20 closed this Mar 13, 2026
@Zero3K20 Zero3K20 deleted the copilot/convert-cpp-to-c branch March 29, 2026 17:33
Zero3K20 added a commit that referenced this pull request Apr 27, 2026
Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants