Results 1 to 8 of 8
I know - Minix is outdated, but it's for a school project.
Attached is my code for the open() command. On compiling, I keep running into the error:
"open.c", Line ...
- 06-26-2009 #1Just Joined!
- Join Date
- Dec 2006
- Posts
- 41
[SOLVED] cc compiler error with char* in Minix
I know - Minix is outdated, but it's for a school project.
Attached is my code for the open() command. On compiling, I keep running into the error:
"open.c", Line 65: . not expected
How helpful. "." Not expected. I have tried multiple ways of declaring this string:
The list continues. I thought maybe I forgot a header, but I don't see what could be missing. Any thoughts? Thanks bunches in advance!Code:char* pathname = (char*)malloc(100); char* pathname = malloc(100); char* pathname = (char*)malloc(100 * sizeof * pathname); char* pathname = (char*)malloc(100 * sizeof *char);
- 06-26-2009 #2
Are you sure that line number 65 in your error message refers to
Code:char* pathname = (char*)malloc(100);
Make mine Arch Linux
- 06-26-2009 #3Just Joined!
- Join Date
- Dec 2006
- Posts
- 41
Very sure. I just double checked. I've had problems getting malloc() syntax right in gcc before, but the Minix cc is really picky. Any thoughts? I really appreciate it.
- 06-26-2009 #4
Well your compiler is having problems with a "." on line 65. Line 65 doesn't have a period so maybe the compiler is a little confused as to where the syntax violation is and this is its best guess...Gerard4143
Make mine Arch Linux
- 06-26-2009 #5Just Joined!
- Join Date
- Dec 2006
- Posts
- 41
Okay, I figured it out, but it doesn't make sense, and I don't understand WHY it was an error. I understand that pathname is both a member of min and a char*. However, simply changing the line to char* path made it work. May Minix die a slow death . . .
- 06-26-2009 #6
Are you saying the compiler expected a "." for the variable pathname because it was also declared as a member of the m_in structure? That is weird...Gerard4143
Make mine Arch Linux
- 06-27-2009 #7Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
What are you trying to do? The last 3 allocations are bogus. First off, on the 2nd example, malloc() returns a void*, not a char*, so this will fail if you are compiling with ANSI compliance or for C++. The 3rd and 4th examples are multiplying either the address of sizeof() on systems where it is a function, or may generate a compiler error where sizeof is a macro. In either case, these are invalid constructs.
So, my guess is that you are trying to compile Minix code with a current GNU C compiler in Linux, correct? That's why you are getting errors. You need to correct the code first.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 06-27-2009 #8Just Joined!
- Join Date
- Dec 2006
- Posts
- 41
Rubberman (awkward name, btw) - I got it to work by changing pathname to path. That worked for some reason. Thanks, anyway!



