Re: Library Design, f0dder's nightmare.




f0dder wrote:

In MS Win32 you can return just EAX and EDX for a HLL.

typedef struct MY_POINTER_AND_COUNT {
DWORD Pointer; // EAX (void *)
DWORD Count; // EDX (long)
} ;

MY_POINTER_AND_COUNT _mycall MyFunc ( ... ) ;

I've used to return SAFEARRAY of BSTRs in the commandline case,
though.

Hm, same way 64bit integers are returned, yes? I wonder how many compilers
support this? (I'd guess intel, VC, GCC - but what about smaller compilers
like DigitalMars?)

It's still pretty irrelevant for code like this tokenizer, though. But it's
worth keeping in mind for stuff that's called more often, sure.

AFAIK, the C standard says you can return structures from a function.
Exactly *how* those structures are returned is implementation
dependent, of course. I don't recall seeing the Intel ABI discuss what
happens when you return a 64-bit struct value, but EDX:EAX makes
perfect sense for most implementations. Of course, Intel's ABI (whether
or not it mentions 64-bit structs) is just a *suggestion*, so you can't
count on that, anyway.
Cheers,
Randy Hyde

.



Relevant Pages

  • Re: A C Adventure: your comments are welcome
    ... struct bar * ref;}; ... Compilers ... The newline is added by formatting. ... hasn't been tested, yet, but it makes a rope node with at most a left ...
    (comp.lang.c)
  • Re: Any way to use fortran90 module in C?
    ... one requirement on a struct, and that is a pointer to the struct works as a pointer to the first element. ... Compilers I know of use padding but not rearranging, though I believe rearranging is allowed. ... the first member, ...
    (comp.lang.fortran)
  • Re: De facto standard size of bit-field objects
    ... It seems that most compilers create the size of the bit-field object ... unsigned char x:4; ... yields a struct with a size of 32 bits, ...
    (comp.lang.c)
  • Re: Why C is really a bad programming language
    ... by compilers with different ideas of the size of time_t? ... You can get pretty close with any ABI that specifies passing arguments ... I don't think a struct argument would be a problem; ... new apps will be linked with the new libraries. ...
    (comp.lang.c)
  • Re: Question on Pointers
    ... Regarding some rather old wording describing a language that is ... was perfectly legal to assign an 'int' value to a pointer), ... struct A { ... To make this compile on today's compilers, ...
    (comp.lang.c)