tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: Steve Feehan <sfeehan@sbb.uvm.edu>
Subject: stat is a macro
Date: Fri, 29 Nov 2002 18:20:39 -0500	[thread overview]
Message-ID: <20021129232039.GA81744@structure.sbb.uvm.edu> (raw)

I've seen several posts regarding the fact that stat, lstat and 
fstat are macros wrapping the _F64_* functions. This works fine
with the compaq c compiler, and with gcc as long as the address
of the function isn't taken. In this case, the compaq compiler
knows what to do. But how to fix the gcc case? The answer I've 
seen in other posts is "use the compaq compiler". No. :) 

As an example of the code I'm refferring to:

#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>

int main(int argc, char * argv[])
{
    struct stat sbuf;
    int err;
    int (*stat_fun)(const char *, struct stat *) = stat;
    err = stat_fun("/dev/null", &sbuf);
    if (err < 0)
    {
        perror("stat_fun");
        return 1;
    }

    return 0;
}

What is the "correct" way to make this work with gcc (or other 
non-compaq compilers)?

Thanks and I will summarize.

-- 
Steve Feehan
Unix Systems Administrator
Structural Biology and Bioinformatics
University of Vermont


                 reply	other threads:[~2002-11-29 23:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox