Page 1 of 1

Errors while using far pointer in c Using gcc on linux

Posted: Wed Jun 07, 2017 8:09 am
by yerri07
I had to use far pointers in Kernel , when i using the far pointer to test i coded to test the following code before using in my kernel . Getting errors.

#include <stdio.h>

int main(){
int a=50;
int far* b;
b=&a;
printf("%Fp",b);

return 0;
}
test.c: In function ‘main’:
test.c:5:13: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
int far* b;
^
test.c:5:15: error: ‘b’ undeclared (first use in this function)
int far* b;
^
test.c:5:15: note: each undeclared identifier is reported only once for each function it appears in

Re: Errors while using far pointer in c Using gcc on linux

Posted: Wed Jun 07, 2017 8:22 am
by mallard
GCC, being a compiler for a 32/64-bit "flat" memory model, doesn't support "far" pointers. "Far" and "near" pointers only make sense in segmented memory arrangements.

Ideally, your kernel would be in 32/64-bit mode with a flat memory model before you even start running C code...

Re: Errors while using far pointer in c Using gcc on linux

Posted: Thu Jun 08, 2017 12:39 am
by iansjack