Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: no member named 'st_atim' in 'struct stat' #7

Closed
ryandesign opened this issue Oct 13, 2018 · 5 comments
Closed

error: no member named 'st_atim' in 'struct stat' #7

ryandesign opened this issue Oct 13, 2018 · 5 comments

Comments

@ryandesign
Copy link

Hello, we have an old version of mg in MacPorts which I'm trying to update to your latest version 20180927. I'm trying to build it on macOS High Sierra.

First, it told me to install libbsd. I tried to build libbsd, but it failed. I reported that to the developers of libbsd. Then, since macOS is based on BSD, I tried patching your makefile so that it would not require a separate libbsd.

That got me further, and now it fails to build for me with this error:

fileio.c:282:20: error: no member named 'st_atim' in 'struct stat'
        new_times[0] = sb.st_atim;
                       ~~ ^
fileio.c:283:20: error: no member named 'st_mtim' in 'struct stat'
        new_times[1] = sb.st_mtim;
                       ~~ ^
2 errors generated.

I've run into this problem with other projects as well. Seems this is just one of those things that different operating systems do differently: macOS doesn't use the names st_atim, st_ctim, st_mtim, but instead uses st_atimespec, st_ctimespec, st_mtimespec.

Since the last release, I see you've added cmake support. Maybe you could have cmake detect which time fields to use on the current OS.

@hboetes
Copy link
Owner

hboetes commented Oct 16, 2018 via email

@blanxd
Copy link

blanxd commented Nov 18, 2018

	#if defined(__APPLE__)
		new_times[0] = sb.st_atimespec;
		new_times[1] = sb.st_mtimespec;
	#else
		new_times[0] = sb.st_atim;
		new_times[1] = sb.st_mtim;
	#endif

I built this for iOS, encountered the same thing.

@hboetes
Copy link
Owner

hboetes commented Nov 18, 2018

Hi there @blanxd,
thanks for your suggestion. Could you make a pull request out of that?

Cheers!

@troglobit
Copy link

Just a heads up, this applies to NetBSD as well. In my port of mg I use the following in defs.h:

#if defined(__APPLE__) || defined(__NetBSD__) 
#define st_atim st_atimespec
#define st_ctim st_ctimespec
#define st_mtim st_mtimespec
#endif

@hboetes
Copy link
Owner

hboetes commented Mar 23, 2019 via email

@hboetes hboetes closed this as completed in b3ab629 Oct 4, 2019
sainnhe added a commit to sainnhe/rofi that referenced this issue Jul 28, 2022
When compiling on macOS, an error message will pop up:

```
error: no member named 'st_atim' in 'struct stat'
```

This is because `st_atim`, `st_ctim` and `st_mtim` does not exist on
macOS, instead it uses `st_atimespec`, `st_ctimespec` and
`st_mtimespec`.

In this commit, 3 macros are defined to try to fix this problem.

Reference: hboetes/mg#7
DaveDavenport pushed a commit to davatorium/rofi that referenced this issue Jul 28, 2022
When compiling on macOS, an error message will pop up:

```
error: no member named 'st_atim' in 'struct stat'
```

This is because `st_atim`, `st_ctim` and `st_mtim` does not exist on
macOS, instead it uses `st_atimespec`, `st_ctimespec` and
`st_mtimespec`.

In this commit, 3 macros are defined to try to fix this problem.

Reference: hboetes/mg#7
g-branden-robinson pushed a commit to g-branden-robinson/mg that referenced this issue Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants