0

I am working on the os161 project. I create a file which include the array.h provide in src/kern/include. When I compile, I had the error like this: ./../include/array.h:85: error: expected '=', ',', ';', 'asm' or 'attribute' before 'unsigned' ../../include/array.h:91: error: expected '=', ',', ';', 'asm' or 'attribute' before 'void'

the code is like:

#ifndef ARRAYINLINE
#define ARRAYINLINE INLINE
#endif

ARRAYINLINE unsigned    --------------line 85 error
array_num(const struct array *a)
{
    return a->num;
}

ARRAYINLINE void *     --------------line 91 error
array_get(const struct array *a, unsigned index)
{
    ARRAYASSERT(index < a->num);
    return a->v[index];
}

and this kind of error happened at every line has something like INLINE or ARRAYINLINE. This array.h file is provided and I made no change to it. Really cannot figure out why.

eric li
  • 1
  • 1
  • Error says that the compiler is not able to understand what `INLINE` is. Maybe `#define ARRAYINLINE INLINE` is `define ARRAYINLINE inline` requesting the compiler to `inline` the functions? If not, is `INLINE` defined while compiling? – another.anon.coward Mar 26 '12 at 09:22
  • 2
    Try to get program text after preprocessor and show it. E.g. for gcc it's option "-E". The most probable variant is no definition of INLINE or strange one. – Netch Mar 26 '12 at 09:30
  • Can you add the const struct array please? And a bit more code as well. What is your command to compile? – Patapoom Mar 26 '12 at 09:22

2 Answers2

1

I'm working on os161, too. INLINE is not defined, try using #define ARRAYINLINE inline instead.

[EDIT]

I checked my os161 revision. I found this line before the #define ARRAYINLINE INLINE

#define INLINE extern inline

So please check if your array.h also contains this line (115 in my case)

[/EDIT]

Jinghao Shi
  • 1,077
  • 2
  • 10
  • 15
-1

I'm working on OS161 as well, this error could be generated if you have a random character outside of your function. Example:

#include <...>
...
e //<-this random character that could have been mistyped.

sys_fork(...){
...
}
SMR
  • 6,628
  • 2
  • 35
  • 56