atommclain
Member
Hello, I am working on porting an old open source project that was originally made to run on System 7 and up, to run on System 6. This is my first foray into classic Mac development, and at best I would consider myself a novice C programmer, but I am slowly making headway. I'm stuck on an issue that I've spent countless hours trying to figure out and would appreciate any insights on how to resolve it.
Where I need help is with the open system call. When the binary is run on System 6, open fails with error number -50, when the same binary is run on System 7 on the same machine open succeeds.
I'm testing with Mini vMac which is compiled with Abnormal Situation Reports enabled. The project was/is based on CodeWarrior and seems somewhat reliant on it. I've upgraded Universal Headers to MPW GM version, which itself has a version of open, but I can't seem to get it to prioritize over the CodeWarrior standard C version. I also explored seeing if I could use fopen, but it looks like the return value from open is used and open itself is littered throughout the project.
During my attempts at debugging the issue I created a little scratch file to experiment with different C compilers. Open seems to work fine with Think C 5 & 6, MPW, but not with CodeWarrior Pro 2, CodeWarrior Pro 5. CodeWarrior 4 doesn't seem to have open just __open which crashes on System 6, but works on System 7. I tried to test CodeWarrior Pro 6, but couldn't get a scratch application to work. Again, the same binary will work on System 7, just not 6.
I'm hoping that this is an issue where I am not importing the correct headers or libraries or there some project setting I need to change. Any help or suggestions would be GREATLY appreciated!
Where I need help is with the open system call. When the binary is run on System 6, open fails with error number -50, when the same binary is run on System 7 on the same machine open succeeds.
void
testSave()
{
char *path = "Macintosh HD:testFile";
int flags = O_RDWR|O_CREAT|O_EXCL;
int fd;
fd = open(path, flags);
if (fd < 0) {
// Failing here on System 6 with CodeWarrior Pro 2 & 5
// Works on System 7
}
}
I'm testing with Mini vMac which is compiled with Abnormal Situation Reports enabled. The project was/is based on CodeWarrior and seems somewhat reliant on it. I've upgraded Universal Headers to MPW GM version, which itself has a version of open, but I can't seem to get it to prioritize over the CodeWarrior standard C version. I also explored seeing if I could use fopen, but it looks like the return value from open is used and open itself is littered throughout the project.
During my attempts at debugging the issue I created a little scratch file to experiment with different C compilers. Open seems to work fine with Think C 5 & 6, MPW, but not with CodeWarrior Pro 2, CodeWarrior Pro 5. CodeWarrior 4 doesn't seem to have open just __open which crashes on System 6, but works on System 7. I tried to test CodeWarrior Pro 6, but couldn't get a scratch application to work. Again, the same binary will work on System 7, just not 6.
I'm hoping that this is an issue where I am not importing the correct headers or libraries or there some project setting I need to change. Any help or suggestions would be GREATLY appreciated!