Skip to content

Conversation

@GitMensch
Copy link
Collaborator

@GitMensch GitMensch commented Aug 13, 2025

note: while _POSIX_TIMERS may be "indirectly" defined by including time.h on some systems, they come from unistd.h.

tested to work on Debian and MSYS2 (gcc + clang)

fixes #345 (C part)

to be checked:
Is there an environment where this does not work (it seems that on non-released mingwrt we do have the feature with clock_gettime since Dec 2017 but no posix-feature-macros at all; not sure if this is something to care for)?

Should we apply something similar to other places? See https://linux.die.net/man/7/posixoptions.

note: while _POSIX_TIMERS is "directly" defined by including time.h on some systems, it may only be done if the internal macros are defined, which is commonly done by including unistd.h, so that is done before

tested to work on Debian and MSYS2 (gcc + clang)

fixes #345 (C part)
@GitMensch GitMensch requested a review from Bill-Gray August 13, 2025 07:23
@GitMensch GitMensch marked this pull request as draft August 13, 2025 07:24
@GitMensch GitMensch changed the title use POSIX feature macro do check for clock_gettime use POSIX feature macro to check for clock_gettime Aug 13, 2025
@GitMensch GitMensch marked this pull request as ready for review September 15, 2025 06:38
@GitMensch
Copy link
Collaborator Author

ping @Bill-Gray for review/merge

@Bill-Gray
Copy link
Owner

I just tried building WinGUI and WinCon, cross-compiling on my Linux box. For both, I got :

x86_64-w64-mingw32-gcc -Wl,--out-implib,pdcurses.a -static-libgcc -shared -o pdcurses.dll addch.o addchstr.o addstr.o attr.o beep.o bkgd.o border.o clear.o color.o debug.o delch.o deleteln.o getch.o getstr.o getyx.o inch.o inchstr.o initscr.o inopts.o insch.o insstr.o instr.o kernel.o keyname.o mouse.o move.o outopts.o overlay.o pad.o panel.o printw.o refresh.o scanw.o scr_dump.o scroll.o slk.o termattr.o terminfo.o touch.o util.o window.o pdcclip.o pdcdisp.o pdcgetsc.o pdckbd.o pdcscrn.o pdcsetsc.o pdcutil.o -lgdi32 -lcomdlg32 -lwinmm
/usr/bin/x86_64-w64-mingw32-ld: getch.o:getch.c:(.text+0x61e): undefined reference to `clock_gettime'
/usr/bin/x86_64-w64-mingw32-ld: getch.o:getch.c:(.text+0xe8c): undefined reference to `clock_gettime'
collect2: error: ld returned 1 exit status
make: *** [Makefile:155: pdcurses.dll] Error 1

So... compiled without trouble, but couldn't link. Presumably, there's something a little more subtle about when the various timing functions are available to us... any ideas?

I also built with Digital Mars and OpenWATCOM 1.9, each for DOS and WinCon, and it all worked and the resulting testcurs.exe files worked in DOSBox and the Wine console, respectively.

I also compiled everything with both of those compilers for OS/2. I mention this just for completeness, since I don't actually have an OS/2-capable machine on which to test the results. I got build errors with DMC, but I've had those before (don't know why); it's not related to the current issue. With OpenWATCOM, everything compiled without warnings or errors.

So I think if we can figure out a fix for the above error message, we'd be good.

@GitMensch
Copy link
Collaborator Author

For clock_gettime we'd nee to add -lrt (for glibc only necessary before 2.17, see https://www.man7.org/linux/man-pages/man3/clock_gettime.3.html - but likely no problem to do so in any case), no?

Can you please test if adding it to the Makefile(s) works for your other build environments?

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.

MinGW: getch.c does not build, no option to work around via Makefile

2 participants