davea42 / libdwarf-code

Contains source for libdwarf, a library for reading DWARF2 and later DWARF. Contains source to create dwarfdump, a program which prints DWARF2 and later DWARF in readable format. Has a very limited DWARF writer set of functions in libdwarfp (producer library). Builds using GNU configure, meson, or cmake.
Other
173 stars 70 forks source link

build failed on windows for error C2371: 'off_t': redefinition; different basic types #263

Closed xiedeacc closed 2 months ago

xiedeacc commented 2 months ago

success after comment code in libdwarf_private.h windows 10 vs2022 sdk: 10.0.22621.0 image

error log

>D:\code\libdwarf-code\src\lib\libdwarf\dwarf_line_table_reader_common.h(2658,29): warning C4996: 'ctime': This function or variable may be unsafe. Consider using ctime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>D:\code\libdwarf-code\src\lib\libdwarf\dwarf_print_lines.c(389,44): warning C4996: 'ctime': This function or variable may be unsafe. Consider using ctime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>D:\code\libdwarf-code\src\lib\libdwarf\dwarf_seekr.c(189,10): warning C4996: '_open': This function or variable may be unsafe. Consider using _sopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\sys\types.h(46,24): error C2371: 'off_t': redefinition; different basic types
1>    19 Warning(s)
1>    1 Error(s)
1>
davea42 commented 2 months ago

I've built under Win10 msys2 (configure,cmake,ninja, and Visual Studio (cmake)

I don't have any idea (at the moment) why yours is failing. Will have to wait a day or to before commenting further.

Do you have any ideas why this is failing for you? I wonder why those defines started causing you trouble.

xiedeacc commented 2 months ago

it turned out my enviroment problem, header conflication

xiedeacc commented 2 months ago

C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\sys\types.h contain a macro for off_t, why not use that macro directly? @davea42

davea42 commented 2 months ago

off_t is used in dwarf_seekr.c (and only there).

I was under the impression that io.h would contain definitions of lseek() off_t and ssize_t but... looking at the relevant headers it appears not to be the case (now anyway).

It builds fine in the VS case just #include "sys/types.h"

I am considering removing those ifdef from libdwarf_private.h and if _MSC_VER defined do include of sys/types.n in dwarf_seekr.c. Since only dwarf_seekr.c refers to off_t.

Thoughts anyone? David Anderson