Errors while using far pointer in c Using gcc on linux

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
yerri07
Member
Member
Posts: 26
Joined: Sat Apr 29, 2017 6:56 am

Errors while using far pointer in c Using gcc on linux

Post 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
mallard
Member
Member
Posts: 280
Joined: Tue May 13, 2014 3:02 am
Location: Private, UK

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

Post 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...
Image
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

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

Post by iansjack »

Post Reply