[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] How to use functions which return struct?
From: |
grischka |
Subject: |
Re: [Tinycc-devel] How to use functions which return struct? |
Date: |
Mon, 04 Oct 2010 23:48:15 +0200 |
User-agent: |
Thunderbird 2.0.0.23 (Windows/20090812) |
Tovarisch wrote:
All greetings,
There is a necessity to use function div, returned value of function -
structure.
After it has appeared that in structure the garbage comes back, i lookd In
stdlib.c and has found the following:
What stdlib.c?
Anyway you are right that on windows there is a special convention
to return a structure in registers (eax/edx) when it fits, and this
is not implemented currently in tinycc, which always return structures
on stack space via an extra function parameter.
Options:
1) don't use such functions
2) define them yourself and compile by tinycc, like
div_t div(int n, int d)
{
div_t r;
r.quot = n / d, r.rem = n % d;
return r;
}
3) teach tinycc to do the right thing.
--- grischka
/*
* div_t and ldiv_t are structures used to return the results of div and
* ldiv.
*
* NOTE: div and ldiv appear not to work correctly unless
*-fno-pcc-struct-return is specified. This is included in the
* mingw32 specs file.
*/
But according to the description "-fno" the negation key, and "-pcc-struct-return" there isn't present.
And as a result this key hasn't helped me.
If someone faced with similar, help please.