stat is a macro

From: Steve Feehan (sfeehan@sbb.uvm.edu)
Date: Fri Nov 29 2002 - 18:20:39 EST


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


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:49:00 EDT