G
Gary Schnabl
What might the problems be in the following code?:
The problems occur at these two lines:
<snippage>
p.L2 = {5,6,10,12,255};
<snippage>
q={{0,0,5,6,128},{5,6,-10,6,128},1};
<...>
The error messages are presented after the source code.
Gary Schnabl
Detroit
****************************************************
#include <hidef.h> /* common defines and macros */
#include <mc9s12c32.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12c32"
void Setp(void);
struct theline {
int x1,y1; // starting point
int x2,y2; // starting point
char color; // color
};
typedef struct theline line;
struct thepath {
line L1,L2; // two lines
char direction;
};
typedef struct thepath path;
path p; // global
void Setp(void) { line myLine; path q;
p.L1.x1=5; // black line from 5,6 to 10,12
p.L1.y1=6;
p.L1.x2=10;
p.L1.y2=12;
p.L1.color=255;
p.L2 = {5,6,10,12,255};
// black line from 5,6 to 10,12
p.direction=-1;
myLine=p.L1;
q={{0,0,5,6,128},{5,6,-10,6,128},1};
q=p;
};
void main(void) {
/* put your own code here */
EnableInterrupts;
for(; {} /* wait forever */
}
***************************************************************
Error messages:
Error : C2450: Expected: . * + - & ! ~ ++ -- -> [ ( IDENT CONSTANT
STRING sizeof __alignof__ __va_sizeof__ __va_arg_type__
main.c line 30
Error : C1822: Type mismatch (expected 'theline ', given 'error ')
main.c line 30
Error : C1806: Illegal cast-operation
main.c line 30
Error : C2801: ';' missing
main.c line 30
Error : C2450: Expected: . * + - & ! ~ ++ -- -> [ ( IDENT CONSTANT
STRING sizeof __alignof__ __va_sizeof__ __va_arg_type__
main.c line 34
Error : C1822: Type mismatch (expected 'thepath ', given 'error ')
main.c line 34
Error : C1806: Illegal cast-operation
main.c line 34
Error : C2801: ';' missing
main.c line 34
Error : C2801: '}' missing
main.c line 34
Error : C2801: ';' missing
main.c line 34
Error : C2801: '}' missing
main.c line 34
Error : Compile failed
The problems occur at these two lines:
<snippage>
p.L2 = {5,6,10,12,255};
<snippage>
q={{0,0,5,6,128},{5,6,-10,6,128},1};
<...>
The error messages are presented after the source code.
Gary Schnabl
Detroit
****************************************************
#include <hidef.h> /* common defines and macros */
#include <mc9s12c32.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12c32"
void Setp(void);
struct theline {
int x1,y1; // starting point
int x2,y2; // starting point
char color; // color
};
typedef struct theline line;
struct thepath {
line L1,L2; // two lines
char direction;
};
typedef struct thepath path;
path p; // global
void Setp(void) { line myLine; path q;
p.L1.x1=5; // black line from 5,6 to 10,12
p.L1.y1=6;
p.L1.x2=10;
p.L1.y2=12;
p.L1.color=255;
p.L2 = {5,6,10,12,255};
// black line from 5,6 to 10,12
p.direction=-1;
myLine=p.L1;
q={{0,0,5,6,128},{5,6,-10,6,128},1};
q=p;
};
void main(void) {
/* put your own code here */
EnableInterrupts;
for(; {} /* wait forever */
}
***************************************************************
Error messages:
Error : C2450: Expected: . * + - & ! ~ ++ -- -> [ ( IDENT CONSTANT
STRING sizeof __alignof__ __va_sizeof__ __va_arg_type__
main.c line 30
Error : C1822: Type mismatch (expected 'theline ', given 'error ')
main.c line 30
Error : C1806: Illegal cast-operation
main.c line 30
Error : C2801: ';' missing
main.c line 30
Error : C2450: Expected: . * + - & ! ~ ++ -- -> [ ( IDENT CONSTANT
STRING sizeof __alignof__ __va_sizeof__ __va_arg_type__
main.c line 34
Error : C1822: Type mismatch (expected 'thepath ', given 'error ')
main.c line 34
Error : C1806: Illegal cast-operation
main.c line 34
Error : C2801: ';' missing
main.c line 34
Error : C2801: '}' missing
main.c line 34
Error : C2801: ';' missing
main.c line 34
Error : C2801: '}' missing
main.c line 34
Error : Compile failed