LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-29-2004, 04:15 AM   #1
sheenak
LQ Newbie
 
Registered: Apr 2004
Posts: 23

Rep: Reputation: 15
HANDLE support for Linux


Hi, I am working on a Project which was using the Windows based Platform. I wish to make it work on the Linux Platform.

In a file which is using a term HANDLE (i suppose being defined in Windows.h File), i am facing problem.

Can any one suggest some alternative for this definition ?


thanks

Sheena !
 
Old 04-29-2004, 08:25 AM   #2
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
A HANDLE in Windows, is basically a void* that is used to identify a resource. (fonts, bitmaps, windows, etc.) In WinNT.h, it is defined as:

typedef void *HANDLE;
 
Old 04-30-2004, 06:33 AM   #3
ashwinipahuja
Member
 
Registered: Mar 2004
Posts: 79

Rep: Reputation: 15
Yes thats fine
But What is the substitue in Linux.
I want to make my source code running!!!!
 
Old 04-30-2004, 08:30 AM   #4
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
As I said already:

typedef void *HANDLE;

If you are trying to convert something that gives you a specific type of HANDLE you are going to have to be a LOT more specific, because for obvious reasons, the Win32 API calls do not work under Linux.
 
Old 05-01-2004, 02:14 AM   #5
sheenak
LQ Newbie
 
Registered: Apr 2004
Posts: 23

Original Poster
Rep: Reputation: 15
Can any one let me know :

How to make HANDLE work in Linux....from the source files which were running in Windows system
 
Old 05-01-2004, 11:25 AM   #6
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
A void* works equally fine under linux or any other O/S, even when called HANDLE.
The problem is not with this type name, but with the rest of the code you want to port.
Instead of trying that, one way to explore could be using Wine to make your program directly run under linux.
 
Old 05-01-2004, 11:57 AM   #7
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
iirc, a handle is actually a DWORD, aka u_int; usually just a small unsigned integer identifier.
 
Old 05-01-2004, 10:10 PM   #8
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
Quote:
Originally posted by infamous41md
iirc, a handle is actually a DWORD, aka u_int; usually just a small unsigned integer identifier.
The typedef I posted is pulled right out of winnt.h. The way it's used, it isn't conceptually that much different from a DWORD, though.
 
Old 05-02-2004, 12:53 PM   #9
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
my bad, thanks for clearin up. and yup i guess u can cast it to w/e u want anyhow
 
Old 05-03-2004, 12:48 AM   #10
nodger
Member
 
Registered: Oct 2003
Location: Ireland
Distribution: Slackware 9.1, Ubuntu
Posts: 192

Rep: Reputation: 30
isn`t a file descriptor the Linux equivalent of a handle?
 
Old 05-03-2004, 05:38 AM   #11
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
no, a file descriptor directly map to a kernel per process table allowing read an write operations to files and sockets, while a handle is working at libray level to access things like windows, fonts, nothing about kernel nor I/O ...
 
Old 05-03-2004, 08:18 AM   #12
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
Quote:
Originally posted by jlliagre
no, a file descriptor directly map to a kernel per process table allowing read an write operations to files and sockets, while a handle is working at libray level to access things like windows, fonts, nothing about kernel nor I/O ...
That's not completely accurate. There is an HANDLE in Win32 that is returned and used by functions like CreateFile, WriteFile, ReadFile, etc.

Anyway, unless the original poster tells us EXACTLY what functions he's trying to get to work in Linux there is no way anyone can tell him what the equivalent would be in Linux. My suggestion to him would be to learn one of the GUI APIs for linux like GDK+, then try to learn at least enough about the Win32 API that he can understand how he needs to port it. (Or whatever his app is currently using, be it MFC, OWL, etc..) It's either that or trying to get it working with wine, as someone else already mentioned.

Just knowing that a HANDLE is really a void* likely isn't going to be enough...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Pentium 2 400 - will it handle linux lava420 Linux - Newbie 25 02-28-2005 09:31 PM
What can these linux servers handle? sendas4 Linux - Networking 3 09-16-2004 06:07 PM
howto handle interrupts in linux cheema Programming 3 07-08-2004 01:44 AM
how does linux handle memory allocation? nodger Programming 4 04-17-2004 10:10 PM
Linux can't handle the pressure linus Linux - General 47 04-25-2003 04:56 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration