Respected gurus,
I have a rather theoretical series of questions. I've been dabbling with C over the years but have finally come to the point where I need to resolve some fundamental questions... (It may help you to know that I come from the Java world.)
1) From what I understand, it is generally unfeasible to try to write C code that runs across all platforms that have a C compiler, like you write code in Java that covers all platforms by definition. For instance, from what I know, even such a thing as the number of bits in a primitive could vary between platforms in the C world. So, if I understand it right, if a programmer wants his C code to run on platform X in addition to his favorite platform Y, he has to explicitly review his code with platform X in mind and possibly insert some pre-processor instructions into the source code (to the effect: "if compiling on platform X, use this primitive or this class or library"). Is my understanding of this right?
2) If generic all-platform code in C is indeed unfeasible, how come we do talk of language C in general, in pan-platform terms? Is it just because a number of different platforms have adopted common standards, but still provide own implementations of those standards?
3) If it is indeed all about common C cross-platform standards, then where can one learn more about them?
4) Who defines those standards?
5) Could you please name some libraries that are standard and available on multiple platforms? I know of "the standard C library", naturally, and I suspect it fits in this category. I also suspect such things as socket-manipulation may also be pretty standard. Could anyone please clarify?
6) How similar is the situation in the C++ world?
Thanks in advance for your insights,
Dmitri Pisarev.
I have a rather theoretical series of questions. I've been dabbling with C over the years but have finally come to the point where I need to resolve some fundamental questions... (It may help you to know that I come from the Java world.)
1) From what I understand, it is generally unfeasible to try to write C code that runs across all platforms that have a C compiler, like you write code in Java that covers all platforms by definition. For instance, from what I know, even such a thing as the number of bits in a primitive could vary between platforms in the C world. So, if I understand it right, if a programmer wants his C code to run on platform X in addition to his favorite platform Y, he has to explicitly review his code with platform X in mind and possibly insert some pre-processor instructions into the source code (to the effect: "if compiling on platform X, use this primitive or this class or library"). Is my understanding of this right?
2) If generic all-platform code in C is indeed unfeasible, how come we do talk of language C in general, in pan-platform terms? Is it just because a number of different platforms have adopted common standards, but still provide own implementations of those standards?
3) If it is indeed all about common C cross-platform standards, then where can one learn more about them?
4) Who defines those standards?
5) Could you please name some libraries that are standard and available on multiple platforms? I know of "the standard C library", naturally, and I suspect it fits in this category. I also suspect such things as socket-manipulation may also be pretty standard. Could anyone please clarify?
6) How similar is the situation in the C++ world?
Thanks in advance for your insights,
Dmitri Pisarev.