Skip to content

Optional mp_fprintf#603

Open
czurnieden wants to merge 2 commits into
libtom:developfrom
czurnieden:mp_fprintf
Open

Optional mp_fprintf#603
czurnieden wants to merge 2 commits into
libtom:developfrom
czurnieden:mp_fprintf

Conversation

@czurnieden

Copy link
Copy Markdown
Contributor

It is quiet a large addition and therefore optional. It can be build by defining MP_WITH_MP_FPRINTF (Cmake got an option to do that, too). But is is tested by testme.sh no matter what.

Not everything from C23 is implemented, mainly because most of the compilers have not implemented everything either.
It works by parsing the '%' tokens, convert the big integers manually and pushing all of the rest to fprintf(3) to handle.
The modifier for bigints is Z and there is also a specifier K to print in radix 64.

@czurnieden

Copy link
Copy Markdown
Contributor Author

I think I broke something:

cl /nologo /I./ /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /D__STDC_WANT_SECURE_LIB__=1 /D_CRT_HAS_CXX17=0 /Wall /wd4146 /wd4127 /wd4668 /wd4710 /wd4711 /wd4820 /wd5045 /WX /DMP_WITH_MP_FPRINTF /wd4061 /wd4774 /c demo/shared.c /Fodemo/shared.obj
shared.c
	cl /nologo /I./ /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /D__STDC_WANT_SECURE_LIB__=1 /D_CRT_HAS_CXX17=0 /Wall /wd4146 /wd4127 /wd4668 /wd4710 /wd4711 /wd4820 /wd5045 /WX /DMP_WITH_MP_FPRINTF /wd4061 /wd4774 /c demo/test.c /Fodemo/test.obj
test.c
	link   advapi32.lib tommath.lib demo/shared.obj demo/test.obj /out:test.exe
Microsoft (R) Incremental Linker Version 14.44.35219.0
Copyright (C) Microsoft Corporation.  All rights reserved.
test.obj : error LNK2019: unresolved external symbol does_not_exist referenced in function uabs64
test.obj : error LNK2019: unresolved external symbol pthread_create referenced in function thread_start
test.obj : error LNK2019: unresolved external symbol pthread_join referenced in function thread_join
tommath.lib(s_mp_rand_platform.obj) : error LNK2019: unresolved external symbol s_read_arc4random referenced in function s_mp_rand_platform
tommath.lib(s_mp_rand_platform.obj) : error LNK2019: unresolved external symbol s_read_getrandom referenced in function s_mp_rand_platform
tommath.lib(s_mp_rand_platform.obj) : error LNK2019: unresolved external symbol s_read_urandom referenced in function s_mp_rand_platform
test.exe : fatal error LNK1120: 6 unresolved externals
NMAKE : fatal error U1077: 'link   advapi32.lib tommath.lib demo/shared.obj demo/test.obj /out:test.exe' : return code '0x460'
Stop.

But I am not sure what exactly.

@czurnieden

czurnieden commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

But I am not sure what exactly.

It was the missing optimization that did not make it from makefile.msvc to appveyor. The
unresolved external symbol does_not_exist referenced
gave it away. Dead code elimination needs at least basic optimization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant