Re: statfs(), xforms, and linux

Ivan Powis (pczip@chemistry.nottingham.ac.uk)
Mon, 28 Apr 1997 9:40:00 BST

To subscribers of the xforms list from Ivan Powis <pczip@chemistry.nottingham.ac.uk> :

>
> To subscribers of the xforms list from "Robert S. Mallozzi" <mallors@ips1.msfc.nasa.gov> :
>
>
> Ha, when I change the program as follows, everything works. Thanks for
> the hint, Ivan
>
>
> struct statfs buf;
>
> statfs("/", &buf);
>
>
> My apologies for posting c questions to the xforms list ;-)
> I am still unsure why *buf does not work under linux (works fine on
> SGI...).
>

I'm no C expert and have no direct experience of either of your
systems, but older C compilers I've used would pass the _address_ of any
parameter object >4 bytes when making a function call - thus
statfs("/",buff) would be equivalent to statfs("/",&buff). I presume
this behaviour was associated with the fact that originally K&R C did
not permit structure assignments and was rather ambiguous in this
whole area. Newer (ANSI ?) compilers will however make a copy of a
passed structure on the called function's stack so that passing a
structure is quite distinct from passing its address.

Presumably you were not using ANSI C (or else you would have seen
prototype warnings about incorrect parameter types?) so that in one
case your compiled code defaulted to the older argument passing
convention and worked, while in the other it failed.

Ivan

--
-------------------------------------------------------------------------+
    ___  ___/   _  __ /  Ivan Powis                TEL: +44-115-951-3467 |
        /         /   /  Department of Chemistry   FAX: +44-115-951-3562 |
       /         /  _/   University of Nottingham                        |
      /         ___/     Nottingham NG7 2RD                              |
     /         /         UK                                              |
    /         /                      pczip@chem.nott.ac.uk               | 
_______/  ____/                      http://www.chem.nott.ac.uk/IP.html  |
-------------------------------------------------------------------------+

_________________________________________________ To unsubscribe, send the message "unsubscribe" to xforms-request@bob.usuf2.usuhs.mil or see http://bob.usuf2.usuhs.mil/mailserv/xforms.html Xforms Home Page: http://bragg.phys.uwm.edu/xforms List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/xforms-archive/