Unable to open file include: 'android / api-level.h': in Visual Studio Code 2017

Please help me I tried to compile this source code in C ISO Std using in the include header <sys/stat.h> :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <time.h>
  
void printFileProperties(struct stat stats);

int main()
{
    char path[100];
    struct stat stats;

    printf("Enter source file path: ");
    scanf("%s", path);


    // stat() returns 0 on successful operation,
    // otherwise returns -1 if unable to get file properties.
    if (stat(path, &stats) == 0)
    {
        printFileProperties(stats);
    }
    else
    {
        printf("Unable to get file properties.\n");
        printf("Please check whether '%s' file exists.\n", path);
    }

    return 0;
}

void printFileProperties(struct stat stats)
{
    struct tm dt;

    // File permissions
    printf("\nFile access: ");
    if (stats.st_mode & R_OK)
        printf("read ");
    if (stats.st_mode & W_OK)
        printf("write ");
    if (stats.st_mode & X_OK)
        printf("execute");

    // File size
    printf("\nFile size: %d", stats.st_size);

    // Get file creation time in seconds and 
    // convert seconds to date and time format
    dt = *(gmtime(&stats.st_ctime));
    printf("\nCreated on: %d-%d-%d %d:%d:%d", dt.tm_mday, dt.tm_mon, dt.tm_year + 1900, dt.tm_hour, dt.tm_min, dt.tm_sec);

    // File modification time
    dt = *(gmtime(&stats.st_mtime));
    printf("\nModified on: %d-%d-%d %d:%d:%d", dt.tm_mday, dt.tm_mon, dt.tm_year + 1900,dt.tm_hour, dt.tm_min, dt.tm_sec);

}  


However VSC 2017 Prompt Developer reports fatal error.
C: \ Arquivos de programas (x86) \ Microsoft Visual Studio \ 2017 \ Community \ Common7 \ Tools> cl find_properties.c

C: \ Arquivos de programas (x86) \ Windows Kits \ 10 \ include \ 10.0.17763.0 \ ucrt \ sys / cdefs.h (246): erro fatal C1083: Não é possível abrir o arquivo de inclusão: 'android / api-level.h ': No such this file or directory.

Thanks
Hello donovan68,

I am not sure about your installation of VS, but my installation does not have "sys/stat.h" in the normal include path.

Doing a Google search with "visual studio 2017 stat.h" I found this: https://stackoverflow.com/questions/49184227/cannot-open-source-file-sys-types-h-sys-stat-h This may be of some help.

The paths noted: "C:\Program Files (x86)\Windows Kits\10\Include\10", but after the 10 it may be different for you.

Do the search and you may find some other useful links.

Andy
Topic archived. No new replies allowed.