473,396 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

use of FAR pointers with gcc

Hi guys,

sorry to ask this stupid question but how can i use far pointers in gcc ?

see, in tc i have something like :

int far *ptr= 0xb8000000;

gcc doesnt seem to have a far keyword
thanks

Nov 14 '05 #1
9 6402
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

tanuki wrote:
Hi guys,

sorry to ask this stupid question but how can i use far pointers in gcc ?

see, in tc i have something like :

int far *ptr= 0xb8000000;

gcc doesnt seem to have a far keyword


'far' is not a C keyword

'far' is a keyword in /some/ extensions to C, and apparently not in gcc.

In other words, you can't use far pointers in gcc, and 'far' is not a part of
the C language.

- --
Lew Pitcher
IT Consultant, Enterprise Application Architecture,
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFAuzu5agVFX4UWr64RAuitAKDGzTfMwwyn73PpfI74NH Ku1wjJQQCfTuw3
fKlM7qaIkdAms2JfdbgkCKE=
=UDkq
-----END PGP SIGNATURE-----
Nov 14 '05 #2
tanuki wrote:

Hi guys,

sorry to ask this stupid question but how can i use far pointers in gcc ?

see, in tc i have something like :

int far *ptr= 0xb8000000;

gcc doesnt seem to have a far keyword

thanks


No, gcc doesn't have a "far" keyword, as _far_ as I know... :)

What code from what architecture are you porting,
and to what architecture (I'm guessing Intel -> ??)?

You example looks `hardware'ish and may have
no meaning in the new architecture/OS.
Stephen
Nov 14 '05 #3
well, i'm using gcc under windows on ia32 to point to video memory so that
i can write some stuff to that

i suppose that this would work under linux too if the program was executed
as root

if i just try something like long *ptr 0xb8000000
and write to it linux gives me a segfault and windows gives me a
"read/write" error

sorry about all this, i'm just really starting to learn the language
"Stephen L." <sd*********@cast-com.net> wrote in message
news:40***************@cast-com.net...
tanuki wrote:

Hi guys,

sorry to ask this stupid question but how can i use far pointers in gcc ?
see, in tc i have something like :

int far *ptr= 0xb8000000;

gcc doesnt seem to have a far keyword

thanks


No, gcc doesn't have a "far" keyword, as _far_ as I know... :)

What code from what architecture are you porting,
and to what architecture (I'm guessing Intel -> ??)?

You example looks `hardware'ish and may have
no meaning in the new architecture/OS.
Stephen

Nov 14 '05 #4
In article <c9**********@ctb-nnrp2.saix.net>,
tanuki <ph***@sadomain.co.za> wrote:
if i just try something like long *ptr 0xb8000000
and write to it linux gives me a segfault and windows gives me a
"read/write" error


You seem to be expecting the video memory to exist at a specific place
in your program's memory. I don't know about Windows, but normal
operating systems like Linux provide virtual memory, and will not map
memory corresponding to devices into your address space unless you
specifically request it.

So your problem is how to map the video memory into your process, and
that will be done by some library function, most likely in conjunction
with opening some device. It's not a problem with your C pointers as
such.

-- Richard
Nov 14 '05 #5
In 'comp.lang.c', "tanuki" <ph***@sadomain.co.za> wrote:
well, i'm using gcc under windows on ia32 to point to video memory so that
i can write some stuff to that

i suppose that this would work under linux too if the program was executed
as root

if i just try something like long *ptr 0xb8000000
and write to it linux gives me a segfault and windows gives me a
"read/write" error

sorry about all this, i'm just really starting to learn the language


This has nothing to do with the C language. It's a matter of system. Some
are unsafe and let you play with the hardware, others try to be safe and they
don't.

If you want to access the hardware from an application, you must use the
services provided by the system (Windows: DirectX or the like).

If you are writing a driver, well, you certainly are not a newbie in C...

--
-ed- get my email here: http://marreduspam.com/ad672570
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-reference: http://www.dinkumware.com/manuals/reader.aspx?lib=c99
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
Nov 14 '05 #6
On Mon, 31 May 2004 18:16:03 +0200, tanuki wrote:
well, i'm using gcc under windows on ia32 to point to video memory so that
i can write some stuff to that

i suppose that this would work under linux too if the program was executed
as root

if i just try something like long *ptr 0xb8000000
and write to it linux gives me a segfault and windows gives me a
"read/write" error

Newer windows version, as well as linux uses virtual memory.
the 0xb8000000 address your process sees, is probably not the
physical adderess 0xb8000000 . You have to use some sort of API
these days to write to the screen, such as DirectX or OpenGL.
Or even the win32/mfc api on windows or X/any gui toolkit on linux.

Nov 14 '05 #7
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nils O. Selåsdal wrote:
On Mon, 31 May 2004 18:16:03 +0200, tanuki wrote:

well, i'm using gcc under windows on ia32 to point to video memory so that
i can write some stuff to that

i suppose that this would work under linux too if the program was executed
as root

if i just try something like long *ptr 0xb8000000
and write to it linux gives me a segfault and windows gives me a
"read/write" error
Newer windows version, as well as linux uses virtual memory.
the 0xb8000000 address your process sees, is probably not the
physical adderess 0xb8000000 .


For that matter
a) that particular address is not guaranteed to be part of the program's memory
map, and 'direct' access to it can cause 'undefined' behaviour (SIGSEGV, memory
corruption, whatever the system deams appropriate).
b) even if the program has access to that address as part of it's memory map,
with virtual memory, that address probably doesn't belong to the same 'real
memory' location as the video memory.

You have to use some sort of API
these days to write to the screen, such as DirectX or OpenGL.
Or even the win32/mfc api on windows or X/any gui toolkit on linux.


On newer versions of MSWindows (WinNT/2K/XP), application programs need special
permissions to access hardware services like video memory. In Linux,
restrictions are even more severe; you need root access /and/ a special API to
get at video memory.
- --
Lew Pitcher
IT Consultant, Enterprise Application Architecture,
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFAu3A+agVFX4UWr64RApJTAJ4o0DV6AzQsnHCLO+HqDS ujL3mfpwCeNxk2
sH44FBHmNDOWWx/ZmxFQcPw=
=ytug
-----END PGP SIGNATURE-----
Nov 14 '05 #8
Thanks for your comments everyone..

I understand now why you would be able to access certain addresspaces
directly.
stupid old DOS programming examples had me somewhat confuzzled...

i was just playing arround with c and thought it might be a good idea to try
and
write directly to video memory :)

"Lew Pitcher" <Le*********@td.com> wrote in message
news:oe*********************@news20.bellglobal.com ...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nils O. Selåsdal wrote:
On Mon, 31 May 2004 18:16:03 +0200, tanuki wrote:

well, i'm using gcc under windows on ia32 to point to video memory so thati can write some stuff to that

i suppose that this would work under linux too if the program was executedas root

if i just try something like long *ptr 0xb8000000
and write to it linux gives me a segfault and windows gives me a
"read/write" error
Newer windows version, as well as linux uses virtual memory.
the 0xb8000000 address your process sees, is probably not the
physical adderess 0xb8000000 .


For that matter
a) that particular address is not guaranteed to be part of the program's

memory map, and 'direct' access to it can cause 'undefined' behaviour (SIGSEGV, memory corruption, whatever the system deams appropriate).
b) even if the program has access to that address as part of it's memory map, with virtual memory, that address probably doesn't belong to the same 'real memory' location as the video memory.

You have to use some sort of API
these days to write to the screen, such as DirectX or OpenGL.
Or even the win32/mfc api on windows or X/any gui toolkit on linux.
On newer versions of MSWindows (WinNT/2K/XP), application programs need

special permissions to access hardware services like video memory. In Linux,
restrictions are even more severe; you need root access /and/ a special API to get at video memory.
- --
Lew Pitcher
IT Consultant, Enterprise Application Architecture,
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFAu3A+agVFX4UWr64RApJTAJ4o0DV6AzQsnHCLO+HqDS ujL3mfpwCeNxk2
sH44FBHmNDOWWx/ZmxFQcPw=
=ytug
-----END PGP SIGNATURE-----

Nov 14 '05 #9
> if i just try something like long *ptr 0xb8000000
and write to it linux gives me a segfault and windows gives me a
"read/write" error


You cannot do this, neither under windows nor under *n*x, since every modern
OS's use virtual memory,
so you cannot rely on a specific address. Besides, a usermode app cannot
access video-memory directly.
If you want to do graphics programming use OpenGL or DirectX, or for simple
things where speed is not important use the GDI API from Windows.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Nov 14 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: Susan Baker | last post by:
Hi, I'm just reading about smart pointers.. I have some existing C code that I would like to provide wrapper classes for. Specifically, I would like to provide wrappers for two stucts defined...
3
by: ozbear | last post by:
This is probably an obvious question. I know that pointer comparisons are only defined if the two pointers point somewhere "into" the storage allocated to the same object, or if they are NULL,...
9
by: Mikhail Teterin | last post by:
Hello! I'd like to have a variable of a pointer-to-function type. The two possible values are of type (*)(FILE *) and (*)(void *). For example: getter = straight ? fgetc : gzgetc; nextchar...
12
by: Lance | last post by:
VB.NET (v2003) does not support pointers, right? Assuming that this is true, are there any plans to support pointers in the future? Forgive my ignorance, but if C# supports pointers and C# and...
14
by: Alf P. Steinbach | last post by:
Not yet perfect, but: http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01.pdf http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01_examples.zip To access the table of...
92
by: Jim Langston | last post by:
Someone made the statement in a newsgroup that most C++ programmers use smart pointers. His actual phrase was "most of us" but I really don't think that most C++ programmers use smart pointers,...
4
by: Josefo | last post by:
Hello, is someone so kind to tell me why I am getting the following errors ? vector_static_function.c:20: error: expected constructor, destructor, or type conversion before '.' token...
25
by: J Caesar | last post by:
In C you can compare two pointers, p<q, as long as they come from the same array or the same malloc()ated block. Otherwise you can't. What I'd like to do is write a function int comparable(void...
54
by: Boris | last post by:
I had a 3 hours meeting today with some fellow programmers that are partly not convinced about using smart pointers in C++. Their main concern is a possible performance impact. I've been explaining...
2
by: StevenChiasson | last post by:
For the record, not a student, just someone attempting to learn C++. Anyway, the problem I'm having right now is the member function detAddress, of object controller. This is more or less, your...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.