Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

converting linux driver to win driver

Status
Not open for further replies.

pukiamak

Technical User
Jul 14, 2006
44
US
Hello Guys,

I am trying to convert linux driver written by someone to win driver. The final code should be OS independent in other words it should know which enviroment it is running on. Should I declare #ifdef __WIN32 in the header file or it is built in? I am not too familiar with driver development in win. Everytime I compiled in VIsual Studio I always get an error msg unexpected #endif. My code is like

main(){
#ifndef __WIN32
*** code
#else
***code
#endif
}

Any ideas?

Thanks,
 
pukiamak said:
The final code should be OS independent in other words it should know which enviroment it is running on.
I don't think it's possible to create a native executable program that can run on Windows & Linux. Something like Java can do that since it uses a byte-code interpreter.
You'll have to compile one file for Windows and another for Linux.
The example you posted should work (although I usually use WIN32 instead of __WIN32). Check if you have any extra #endif lines anywhere.
 
what should i define WIN32 as? I am confused about this one.. what should i write in the header file?

Thanks,
 
Just what you had there...
Code:
#ifdef WIN32
   // Windows code here.
#elif LINUX
   // Linux code here.
#elif SOLARIS
   // If you want Solaris too, put that here...
...
#endif
In the Project Settings, just make sure WIN32 is in the list of Pre-processor Definitions (which it should be by default).
 
alright guys so I developed my code in Visual Studio..but i got this stupid error saying that error LNK2005: int a bla bla already defined in *.obj..I have two files of code that link together..any ideas?
 
never mind guys..i figured the problem out. it seems i need to use extern instead of the include. Anyway I have question do you guuys know how to parse the command line argument. Suppose if I type

-a 64, How can i take the 64?

In Linux it is easy, we can use getopt() or optarg option. But how can we do it in Windows environment?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top