Syntax error in C on AS/400

Even when one knows how to fix a syntax error before able to write English, one can get flabbergasted once in a while.

I am working with an old IBM C compiler on an AS/400 (also known as iSeries) and this compiler gives less clear error messages then modern compilers.

The code below gives me a syntax error:

[code]
typedef struct { /* Stuff */ } MyStruct;

typedef struct {
MyStruct * myStruct; /* SYNTAX ERROR IN THIS LINE */
/* Stuff */
} MyStruct2;
[/code]

The compiler probably means 'Undeclared datatype 'MyStruct' in line x', because when I add a pointer to an unknown data type, it gives a syntax error in that line:

[code]
typedef struct {
AnUnknownDataType * really; /* SYNTAX ERROR IN THIS LINE */
MyStruct * myStruct;
/* Stuff */
} MyStruct2;
[/code]

Anybody has any idea how a datatype can be unknown, although it is defined one line up in the same header file?

Perhaps you might think I've made a typo, so I post the original code below:

[code]
typedef struct {
char ejendom_id[8];
char hervdeel_id[8];
date datum;
long type;
double verzsom;
double premie;
} herv_t;
typedef struct {
herv_t *her; /* Syntax error in this line */
long aantal;
} herv_lt;
[/code]

I hope you have an idea, or at least share my flabbergastedness :).

See ya,
bilderbikkel

Comments

  • There is nothing wrong with the code, but it seems that the compiler is pretty dumb. Maybe it can't fine the "date" type and freaks out because of that? That is, do you get the same error if you type "Bananas datum;" instead in the first struct?
  • : There is nothing wrong with the code, but it seems that the compiler
    : is pretty dumb. Maybe it can't fine the "date" type and freaks out
    : because of that? That is, do you get the same error if you type
    : "Bananas datum;" instead in the first struct?

    Thanks Lundin for your reply. Unluckily, it can find the 'date' type and changing it to 'Bananas' generates a syntax error...

    And yes, the compiler (and linker) that is used at my job are pretty dumb...

    See ya,

    bilderbikkel
  • No idea then, unless you used type or variable names already taken elsewhere in the program.
  • : No idea then, unless you used type or variable names already taken
    : elsewhere in the program.
    :
    Thanks, I checked for this but it was fine.

    I found that there was a function declaration without a semicolon in another file that caused the error (200 lines back!).

    Again, thanks for your help.


    bilderbikkel
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories