Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > How does C work on non-unix?

Reply
Thread Tools

How does C work on non-unix?

 
 
Ryan M
Guest
Posts: n/a
 
      12-23-2003
I've been programming for a while, but most of my experience is on unix.
How do C compilers work on operating systems that weren't written in C?
And that have no libc?

Compiling C on unix seems so easy. Everything in the code either goes
right to machine code, or links to a C library (often libc) or links to
the kernel. Are there libc equivalents on non-unix OSes?

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      12-23-2003
"Ryan M" <(E-Mail Removed)> wrote in message
news:0b0482f904d746f489b46ff240b984ff@news.1usenet .com...
> I've been programming for a while, but most of my experience is on unix.
> How do C compilers work on operating systems that weren't written in C?
> And that have no libc?
>
> Compiling C on unix seems so easy. Everything in the code either goes
> right to machine code, or links to a C library (often libc) or links to
> the kernel. Are there libc equivalents on non-unix OSes?


C (as discussed here) is a platform-independent language, defined
by an international standard.

See:
http://www.angelfire.com/ms3/bchambl...me_to_clc.html
and
http://www.eskimo.com/~scs/C-faq/top.html

-Mike


 
Reply With Quote
 
 
 
 
Seth Morecraft
Guest
Posts: n/a
 
      12-23-2003
Ryan,
Before someone says this is outside the topic of this group, my humble
answer is:
If you are talking about something like an embedded system- usually you
would use a cross-compiler and generate machine code for your specific
target- then run that program on the OS of your target.
Kernels and libs do not have to be written in C for you to use C to
write a program- although it might not be *standard* C.
What target processor/OS are you looking to compile a C program for?
There might be a C compiler out there.
Hope that helps.

Seth

Ryan M wrote:
> I've been programming for a while, but most of my experience is on
> unix. How do C compilers work on operating systems that weren't written
> in C? And that have no libc?
>
> Compiling C on unix seems so easy. Everything in the code either goes
> right to machine code, or links to a C library (often libc) or links to
> the kernel. Are there libc equivalents on non-unix OSes?
>


~ Let us linux ~


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
 
Reply With Quote
 
Kevin Goodsell
Guest
Posts: n/a
 
      12-23-2003
Ryan M wrote:

> I've been programming for a while, but most of my experience is on
> unix. How do C compilers work on operating systems that weren't written
> in C? And that have no libc?
>
> Compiling C on unix seems so easy. Everything in the code either goes
> right to machine code, or links to a C library (often libc) or links to
> the kernel. Are there libc equivalents on non-unix OSes?
>


Why would it be any different? On all hosted implementations (Unix and
otherwise), the OS (or something similar) provides some basic
functionality. The C library may be part of that functionality, or it
may be written separately by making use of that functionality.

Windows happens to provide a dynamic library (msvc.dll or something like
that) that implements the C library. Cygwin does something similar. This
is basically the same thing Unix does, as far as I know. Compilers for
systems that don't have a 'built in' C library usually ship with their
own implementation.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
 
Reply With Quote
 
Kevin Goodsell
Guest
Posts: n/a
 
      12-23-2003
Seth Morecraft wrote:

> Ryan,
> Before someone says this is outside the topic of this group, my humble
> answer is:


If you've been reading this group long enough to expect that answer, you
should have also caught on that top-posting is rude. Please don't do it
anymore.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
 
Reply With Quote
 
Seth Morecraft
Guest
Posts: n/a
 
      12-23-2003
Ok, thanks.

Seth

Kevin Goodsell wrote:
> Seth Morecraft wrote:
>
>> Ryan,
>> Before someone says this is outside the topic of this group, my humble
>> answer is:

>
>
> If you've been reading this group long enough to expect that answer, you
> should have also caught on that top-posting is rude. Please don't do it
> anymore.
>
> -Kevin


~ Let us linux ~


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      12-23-2003
Ryan M wrote:

> I've been programming for a while, but most of my experience is on unix.
> How do C compilers work on operating systems that weren't written in C?


They accept the source code, preprocess it, translate it, and produce object
files. Just like on Unix!

> And that have no libc?


The compiler typically isn't interested in libraries. That's the linker's
job.

> Compiling C on unix seems so easy.


Then why use anything else?

Seriously, though, C is remarkably portable, and you should have little
difficulty obtaining an easy-to-use C compiler for any modern desktop
operating system.

--
Richard Heathfield : http://www.velocityreviews.com/forums/(E-Mail Removed)
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
 
Reply With Quote
 
J. J. Farrell
Guest
Posts: n/a
 
      12-23-2003
Ryan M <(E-Mail Removed)> wrote in message news:<0b0482f904d746f489b46ff240b984ff@news.1usene t.com>...
>
> I've been programming for a while, but most of my experience is on unix.
> How do C compilers work on operating systems that weren't written in C?


In more or less exactly the same way as they work on OSes that were
written in C. Why should the language the OS was written in make any
difference? There are compilers for COBOL, FORTRAN, ADA, and countless
other languages on UNIX that manage perfectly well even though the
OS wasn't written in that language.

> And that have no libc?


The C library is a C thing, not a UNIX thing. If a system offers a
hosted C implementation, it must include the functionality defined
by the C library in whatever way is appropriate for the compiler and
linker tools (or equivalent) on the OS. If it only offers a non-hosted
C implementation (such as is used on some embedded systems, or for
building the UNIX kernel for example) then the main difference is
that it doesn't offer the full C library functionality. In that case
you can't use the C library routines, simple as that.

> Compiling C on unix seems so easy. Everything in the code either goes
> right to machine code, or links to a C library (often libc) or links to
> the kernel.


Just the same as on most other OSes that provide hosted C.

> Are there libc equivalents on non-unix OSes?


Yes - it's a C thing, nothing to do with UNIX.

It sounds like you have some misconception about the relationship
between C and the OS. If you explain why you think there might be a
problem using C on OSes that aren't written in C, someone should be
able to help clear it up for you.
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      12-24-2003
J. J. Farrell wrote:

> It sounds like you have some misconception about the relationship
> between C and the OS.


This is understandable, given the truism that Unix is written in C, and C is
written in Unix.

--
Richard Heathfield : (E-Mail Removed)
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
 
Reply With Quote
 
Kevin Goodsell
Guest
Posts: n/a
 
      12-24-2003
Seth Morecraft wrote:

> Ok, thanks.
>


You've been asked not to top-post, and informed that it's rude, yet you
continue to do it. Is this your way of requesting to be killfiled? Or
are you just ignorant?

Please stop top-posting. If you don't know what that means, find out
before posting again.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
MS work around on text wrapping in a datagrid does not work TB ASP .Net 2 02-22-2006 10:34 PM
Loop Does'nt Work, Hard code does Nick L C++ 10 08-31-2004 08:49 PM
int('2.1') does not work while int(float('2.1')) does Vineet Jain Python 9 04-16-2004 10:12 AM
what does the native keyword do actually ? and how does it work ?when we can use it ? Alek Nazarian Java 7 10-22-2003 04:33 PM



Advertisments