Skip to content

Why does this code always print 0.000000? #98650

Closed Answered by huoyaoyuan
iahung2 asked this question in Q&A
Discussion options

You must be logged in to vote

In short:
Varargs function must be defined as varargs P/Invoke to be used correctly:

static extern void printf(byte* format, __arglist);
printf(b, __arglist(0.12345));

Varargs is only supported on Windows x86/x64. For x86 it matches cdecl which only uses stack, but on x64 there's only fastcall. There is no way to correctly invoke printf on Unix or ARM.

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@huoyaoyuan
Comment options

Comment options

You must be logged in to vote
4 replies
@huoyaoyuan
Comment options

@huoyaoyuan
Comment options

@MichalPetryka
Comment options

@huoyaoyuan
Comment options

Answer selected by jkotas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants