ISSUE+FIX: 'system' is unavailable: not available on iOS

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ISSUE+FIX: 'system' is unavailable: not available on iOS

Bastien Commelongue
Hi,

When trying to build lua (5.3) for iOS the following error is generated in loslib.c (l.151) :
> error: 'system' is unavailable: not available on iOS

Stdlib "int )system(const char*)" call is indeed prohibited for ios / watchos / tvos platforms, in order to fully compile on iOS some extra code needs to be added (was placed just before "os_execute" function definition):

**********

 #if defined(__APPLE__)
      #include "TargetConditionals.h"
      #if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
          #define system(s) ((s)==NULL ? 0 : -1)
      #endif // end iOS
 #elif defined(__ANDROID__)
      #define system(s) ((s)==NULL ? 0 : -1)
 #endif

**********

Maybe there is a better way to handle this, hopefully this will be considered and help to move LUA library a bit closer to a full iOS / mobile platform support.

Thanks,
Bastien Commelongue
Reply | Threaded
Open this post in threaded view
|

Re: ISSUE+FIX: 'system' is unavailable: not available on iOS

Sergey Kovalev
чт, 14 нояб. 2019 г. в 18:34, Bastien Commelongue <[hidden email]>:

> When trying to build lua (5.3) for iOS the following error is generated in loslib.c (l.151) :
> > error: 'system' is unavailable: not available on iOS
>
> Maybe there is a better way to handle this, hopefully this will be considered and help to move LUA library a bit closer to a full iOS / mobile platform support.

You mean something like this?

#include <spawn.h>
extern char **environ;
int isystem(char *cmd) {
    pid_t pid; int status;
    char *argv[] = {"sh", "-c", cmd, 0};
    status = posix_spawn(&pid, "/bin/sh", 0, 0, argv, environ);
    if (status == 0) {
        if (waitpid(pid, &status, 0) == -1) {
            // perror("waitpid");
        }
    }
    return status;
}
#define system(s) isystem(s)

Reply | Threaded
Open this post in threaded view
|

Re: ISSUE+FIX: 'system' is unavailable: not available on iOS

Luiz Henrique de Figueiredo
In reply to this post by Bastien Commelongue
> When trying to build lua (5.3) for iOS the following error is generated in loslib.c (l.151) :
> > error: 'system' is unavailable: not available on iOS

This of course means that iOS is not an ISO C platform, which is what
Lua commits to.
Are there any other departures from ISO C in iOS?