Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Sep 13th, 2006, 3:44 PM   #1
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 155
Rep Power: 3 programmingnoob is on a distinguished road
c-unix-ignorance

so i have to write a c code in unix using gcc, now i was wondering if i can write the code in c in a regular windows compiler first, then run it on unix. but i dont know any good compilers for that!

also, if i try to do that, how would system calls like fork() etc would work, coz arent these calls inherent to unix?

see, i am totally new to c, but i am assuming it'll be a lot like c++.
programmingnoob is offline   Reply With Quote
Old Sep 13th, 2006, 3:50 PM   #2
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
I'm pretty certain that you'll have to compile it using Unix to get it to work on that system. You can write it wherever you want, but the compilation should be done on Unix.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower

Last edited by Mjordan2nd; Sep 13th, 2006 at 4:31 PM.
Mjordan2nd is offline   Reply With Quote
Old Sep 13th, 2006, 4:01 PM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
MJ is correct. Despite our talk about 'portable' code, code as it runs isn't truly portable. It must comply with both the platform (uP type and other hardware design) and the OS, which usually deals with these things in different ways. Portability usually refers to the source code, and not all source is portable. No reason you can't write it in Windows, it's just text, but you probably can't fully compile it correctly. Certainly not if you use Unix things that aren't available under Windows.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Sep 13th, 2006, 4:22 PM   #4
Kennedy
Newbie
 
Join Date: Aug 2006
Location: Alabama
Posts: 26
Rep Power: 0 Kennedy is on a distinguished road
It is very possible to build a compiler to compile code for one machine on another. This is the way, however, I'll warn you. . . it isn't easy.
Kennedy is offline   Reply With Quote
Old Sep 13th, 2006, 5:05 PM   #5
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 155
Rep Power: 3 programmingnoob is on a distinguished road
i agree with you all, thats what i was thinking.

but just for the heck of it and future assignments, may I dare ask the name of a good windows c compiler? I could google it, but your valuable experience will help me!
programmingnoob is offline   Reply With Quote
Old Sep 13th, 2006, 5:39 PM   #6
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
The Mingw port of gcc works. I like the Code::Blocks IDE, although another great alternative is Dev-C++.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Sep 13th, 2006, 6:12 PM   #7
Benoit
Expert Programmer
 
Benoit's Avatar
 
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 579
Rep Power: 5 Benoit is on a distinguished road
Dev-C++ uses Mingw port of GCC as its compiler. I suggest Dev-C++.
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4
Benoit is offline   Reply With Quote
Old Sep 13th, 2006, 6:23 PM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Well, Kennedy, cross-compilers are used all the time in embedded work, but I don't think that was what the OP was seeking....
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Sep 23rd, 2006, 6:06 AM   #9
free-zombie
Programmer
 
free-zombie's Avatar
 
Join Date: May 2006
Location: Bavaria, Germany
Posts: 50
Rep Power: 0 free-zombie is an unknown quantity at this point
Send a message via ICQ to free-zombie Send a message via MSN to free-zombie Send a message via Yahoo to free-zombie
If you want to target windows and unix, you should IMHO compile with gcc all the way or at least regularly test with gcc when developing on windows. If you want to write for unix on windows, using cygwin might work for testing. If you use Code::Blocks, you can just as well scratch windows for writing and leave it for testing.
free-zombie is offline   Reply With Quote
Old Oct 2nd, 2006, 12:03 AM   #10
climbnorth
Newbie
 
Join Date: Oct 2006
Posts: 16
Rep Power: 0 climbnorth is on a distinguished road
I suggest using cygwin to write your c on the windows box. Most likely, all you would need to do is recompile on the unix box.
climbnorth 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unix commands compatible with Windows? titaniumdecoy Bash / Shell Scripting 7 Oct 5th, 2006 8:25 AM
Best Linux or Unix Desktop? Prm753 Coder's Corner Lounge 23 Apr 8th, 2006 11:17 AM
Importing from DLL's on Unix Kaja Fumei Existing Project Development 5 Jan 9th, 2006 7:35 PM
How to run Jave Applets on Unix? sham Other Programming Languages 5 Apr 30th, 2005 7:28 PM
Email a txt file using C in UNIX? willz99ta C 6 Apr 5th, 2005 6:27 PM




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

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