If I want to fill a descriptiontable, e.g. the IDT, I found it easy to use a struct... but I cant get my structs working in C!
if I do something like this:
struct mystruct {
int yadayada;
};
and then..
mystruct i;
i.yadayada = 5;
I get the error message:
idt.c:6: error: request for member `yadayada' in something not a structure or
how come?
Structs in C
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Structs in C
your declaration does not alias "mystruct" to the structure. The correct code would be
Code: Select all
struct mystruct { ... } ;
struct mystruct i;
i.yadayada=5;
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Structs in C
oh, and btw, beware of compiler alignment of fields ...
usually has a size of 8, not of 6 as asm programmers could expect.
is to be preferred to the "expectable" code.
Code: Select all
struct IdtRegister {
word limit;
dword base;
}
Code: Select all
struct ldtRegister {
word padding;
word limit;
dword base;
} IDTR;
lidt(&(IDTR.limit));
Re:Structs in C
Further, if you in fact wanted to alias mystruct to refer to the structure, then you would have to use typedef.your declaration does not alias "mystruct" to the structure.
-m