![]() |
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++. |
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.
|
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.
|
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.
|
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! |
The Mingw port of gcc works. I like the Code::Blocks IDE, although another great alternative is Dev-C++.
|
Dev-C++ uses Mingw port of GCC as its compiler. I suggest Dev-C++.
|
Well, Kennedy, cross-compilers are used all the time in embedded work, but I don't think that was what the OP was seeking....
|
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.
|
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