Hello
I have a weird error occurring, where if I use the function `openpty()` in C program it compiles ok but if I have the exact same code in a C++ program I get a compiler error:
error: 'openpty' was not declared in this scope
Both Xcode projects have the exact same code in one file (main.c and main.cpp respectively).
How can I fix this error?
Code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <termios.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/select.h>
#include <string.h>
#include <pty.h> // error: pty.h: No such file or directory
int main (int argc, const char * argv[]) {
int gps_fdm, gps_fds;
char slave_port_name[256];
int open_res = openpty(&gps_fdm, &gps_fds, slave_port_name, NULL, NULL); // compiler error here
return 0;
}