Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C (http://www.programmingforums.org/forum60.html)
-   -   c-unix-ignorance (http://www.programmingforums.org/showthread.php?t=11306)

programmingnoob Sep 13th, 2006 3:44 PM

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++.

Mjordan2nd Sep 13th, 2006 3:50 PM

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.

DaWei Sep 13th, 2006 4:01 PM

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.

Kennedy Sep 13th, 2006 4:22 PM

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.

programmingnoob Sep 13th, 2006 5:05 PM

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!

Mjordan2nd Sep 13th, 2006 5:39 PM

The Mingw port of gcc works. I like the Code::Blocks IDE, although another great alternative is Dev-C++.

Benoit Sep 13th, 2006 6:12 PM

Dev-C++ uses Mingw port of GCC as its compiler. I suggest Dev-C++.

DaWei Sep 13th, 2006 6:23 PM

Well, Kennedy, cross-compilers are used all the time in embedded work, but I don't think that was what the OP was seeking....

free-zombie Sep 23rd, 2006 6:06 AM

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.

climbnorth Oct 2nd, 2006 12:03 AM

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.


All times are GMT -5. The time now is 12:56 AM.

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