Search code examples
clinuxtimestatlocaltime

Any specific reason why localtime throws warning with struct tm* & stat* , in linux ?


I have this simple code (part of a project) :

void displayFileProperties(struct stat* file,char*  outputProperties , char * path)
{

    struct tm* time;

        // code 
        // code
        time = localtime(&file->st_mtim);


        // code 

}

Where eclipse keeps throwing me a warning :

passing argument 1 of ‘localtime’ from incompatible pointer type [enabled by default]   main.c  /ex4    line 340    C/C++ Problem

Any idea how to fix this ? thanks


Solution

  • st_mtim is a struct timespec (seconds and nanoseconds). You want st_mtime.