Sorry,I know this question may be a little weird,but I feel it is important.
That is--can I program in C without any OS? If the answer is "Yes",how can a C compiler be "Installed" at this kind of situation?
thanx in advance!
a little weird question
Re: a little weird question
You forgot to read the forum rules!
This is not a weird question, as much as an obviously already answered question. You certainly can write C programs that work without any operating system. That is what a kernel written in C is. That's what this website is about. As for how, you can spot the link
The OSDev.org Wiki - Got a question? Search this first!
above. This should be sufficient answer when combined with the forum rules. :-)
This is not a weird question, as much as an obviously already answered question. You certainly can write C programs that work without any operating system. That is what a kernel written in C is. That's what this website is about. As for how, you can spot the link
The OSDev.org Wiki - Got a question? Search this first!
above. This should be sufficient answer when combined with the forum rules. :-)
Re: a little weird question
Hi,
Also, you can't program with a compiler alone. You'd need some way to read compiler errors (virtual terminal, shell?), a way to edit source files, a linker, misc. utilities (e.g. to create/delete directories), etc.
Cheers,
Brendan
A C compiler requires certain things to run (e.g. access to files, memory, etc). Those things are normally provided by an OS. In theory, it may be possible to port a C compiler to run on "bare metal", but to do that you'd end up implementing things like file systems, disk device drivers, etc, and would end up with a limited OS that happens to compile things.dashllh wrote:That is--can I program in C without any OS? If the answer is "Yes",how can a C compiler be "Installed" at this kind of situation?
Also, you can't program with a compiler alone. You'd need some way to read compiler errors (virtual terminal, shell?), a way to edit source files, a linker, misc. utilities (e.g. to create/delete directories), etc.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: a little weird question
Thank you very much for reply ,sortie.sortie wrote:You forgot to read the forum rules!
This is not a weird question, as much as an obviously already answered question. You certainly can write C programs that work without any operating system. That is what a kernel written in C is. That's what this website is about. As for how, you can spot the link
The OSDev.org Wiki - Got a question? Search this first!
above. This should be sufficient answer when combined with the forum rules.
I will follow the rules:D
Re: a little weird question
Thank you very much for providing me useful detailed knowledgeBrendan wrote:Hi,
A C compiler requires certain things to run (e.g. access to files, memory, etc). Those things are normally provided by an OS. In theory, it may be possible to port a C compiler to run on "bare metal", but to do that you'd end up implementing things like file systems, disk device drivers, etc, and would end up with a limited OS that happens to compile things.dashllh wrote:That is--can I program in C without any OS? If the answer is "Yes",how can a C compiler be "Installed" at this kind of situation?
Also, you can't program with a compiler alone. You'd need some way to read compiler errors (virtual terminal, shell?), a way to edit source files, a linker, misc. utilities (e.g. to create/delete directories), etc.
Cheers,
Brendan
I guess what you mean is -- a compiler have to work together with an OS(at least a limited one),am i right?
Re: a little weird question
Hi,
For example; I could imagine a bootable hex editor thing that takes input (hex characters) from the keyboard and "compiles the input" by converting it to integers and "generates output" by storing the integers in memory. In my opinion, a tool like this might be considered a compiler (if you define "compiler" loosely) but wouldn't meet the minimum requirements needed to call itself an OS; and would therefore be a compiler without an OS.
Your original question was specifically about a C compiler though. A C compiler must comply with (at least one version of) the standards that define C; which implies that it must (e.g.) support the "#include" pre-processor directive. This alone means that something resembling file IO (and the ability to store source code to be used later) must exist.
Cheers,
Brendan
That depends on how you define "compiler" and "OS".dashllh wrote:Thank you very much for providing me useful detailed knowledge
I guess what you mean is -- a compiler have to work together with an OS(at least a limited one),am i right?
For example; I could imagine a bootable hex editor thing that takes input (hex characters) from the keyboard and "compiles the input" by converting it to integers and "generates output" by storing the integers in memory. In my opinion, a tool like this might be considered a compiler (if you define "compiler" loosely) but wouldn't meet the minimum requirements needed to call itself an OS; and would therefore be a compiler without an OS.
Your original question was specifically about a C compiler though. A C compiler must comply with (at least one version of) the standards that define C; which implies that it must (e.g.) support the "#include" pre-processor directive. This alone means that something resembling file IO (and the ability to store source code to be used later) must exist.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.