Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 15th, 2004, 7:44 PM   #11
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Good point. I'm officially an idiot. Screw that then - I'll just use different files. Thanks for the help though.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Nov 16th, 2004, 10:51 AM   #12
erebus
Programmer
 
erebus's Avatar
 
Join Date: Aug 2004
Location: /dev/null
Posts: 65
Rep Power: 5 erebus is on a distinguished road
Send a message via AIM to erebus
Quote:
Originally posted by Ooble

Good point. I'm officially an idiot. Screw that then - I'll just use different files. Thanks for the help though.
Actually, you can do something like:
#ifdef _WIN32
  #include <windows.h>
#endif

... common practice in winsock/bsd socket portability. Kinda vague, but you get the idea.
__________________
<span style='font-size:14pt;line-height:100%'><span style='color:red'>&quot;Political power grows out of the barrel of a gun&quot; - Mao Tse-Tung</span></span>
erebus is offline   Reply With Quote
Old Nov 16th, 2004, 3:50 PM   #13
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
That's what I was going for... thought you meant you couldn't do that. So what's the #define for Linux? Is there anything that I could use, or do I just use #else?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Nov 16th, 2004, 6:00 PM   #14
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 6 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
#ifdef _WIN32
  #include <windows.h>
#endif
#ifndef _WIN32
  #include more stuff...
#endif

Hmm.. guess i was wrong.
__________________

tempest is offline   Reply With Quote
Old Nov 17th, 2004, 10:50 AM   #15
erebus
Programmer
 
erebus's Avatar
 
Join Date: Aug 2004
Location: /dev/null
Posts: 65
Rep Power: 5 erebus is on a distinguished road
Send a message via AIM to erebus
_WIN32 for Windows, unix for *BSD/Linux/UNIX, and __OS2__ for OS/2? That's what I remember, though I can't find any references for it.
__________________
<span style='font-size:14pt;line-height:100%'><span style='color:red'>&quot;Political power grows out of the barrel of a gun&quot; - Mao Tse-Tung</span></span>
erebus is offline   Reply With Quote
Old Nov 17th, 2004, 12:13 PM   #16
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
It works! It works! Well, it works on Windows anyway... haven't tested it on Linux yet, but as it's a simple #else command - nothing fancy - it should be fine. The Linux library hasn't been written yet anyway. Now I just need to find out how to work threads - anyone got any links?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Nov 17th, 2004, 1:22 PM   #17
alunw
Newbie
 
Join Date: Nov 2004
Posts: 3
Rep Power: 0 alunw is on a distinguished road
You have to compile your program separately for each platform, so you can just invent your own define and test it

e.g. compiling on Windows cl -DWIN32 fred.cpp

compiling on Linux gcc -Dlinux fred.cpp

etc.

On Unix/Linux make usually uses a variable called CFLAGS or CPPFLAGS and CC when doing compiles so you can sometimes have a makefile that works on multiple platforms
but still detects the OS - something like.

$(CC) $(CFLAGS) fred.cpp

I build my programs to run on everything from Windows CE and MS-DOS through to Windows and AIX, and find this technique works well.
alunw is offline   Reply With Quote
Old Nov 17th, 2004, 2:39 PM   #18
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
That was the plan - I'll see if it works when the Linux sockets library is up and running, and I find someone who knows how to use Linux
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Nov 18th, 2004, 11:34 PM   #19
erebus
Programmer
 
erebus's Avatar
 
Join Date: Aug 2004
Location: /dev/null
Posts: 65
Rep Power: 5 erebus is on a distinguished road
Send a message via AIM to erebus
If you're trying to write portable software, just use the SFU software pack from Microsoft, since it does come equiped with the BSD socket library. It runs a UNIX subsystem natively and you wouldn't really have to learn how to use Linux, just learn some software(of which you're most-likely somehwat familiar with i.e. gcc, gdb...)

http://www.microsoft.com/windows/sfu/
__________________
<span style='font-size:14pt;line-height:100%'><span style='color:red'>&quot;Political power grows out of the barrel of a gun&quot; - Mao Tse-Tung</span></span>
erebus is offline   Reply With Quote
Old Nov 19th, 2004, 11:31 AM   #20
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Wow... never knew that existed. Thanks for the link.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:47 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC