Re: portable C, posix C and windows C



On Oct 8, 12:34 am, asit <lipu...@xxxxxxxxx> wrote:
what is the difference between portable C, posix C and windows C ???

"Portable" has several different meanings with respect to C. One
meaning is that C compilers have been implemented on a wide variety of
platforms where other languages have not; this was a Big Deal back in
the dark ages, now probably not so much. Another meaning is that
there is a single, well-known standard for the C language that most
compilers implement faithfully, as opposed to languages that vary
depending on the platform and vendor (there were multiple, slightly
incompatible versions of Pascal and Fortran floating around when C was
first becoming popular).

For most of us, "portable" means C code that has been written in such
a way that it will build and run on multiple platforms with little or
no change. For example, the canonical "Hello World" program

#include <stdio.h>
int main(void)
{
printf("Hello, World\n");
return 0;
}

should compile and run and give the same results on every platform
without making any changes to the source code, so it's considered
"portable" (what I call trivially portable). As long as your source
code makes no assumptions about word size, byte order, or numerical
representation, and restricts itself to using the standard library
(stdio, stdlib, string, math, etc.), then it should be trivially
portable like the code above.

Unfortunately, C doesn't provide built-in support for a lot of
capabilities that most of us have come to expect in modern software --
graphics, sound, network support, etc., so to do any of that we have
to rely on vendor-specific or third-party libraries that may only
exist on specific platforms. For example, if you took the source code
for Microsoft Word for Windows and tried to compile and run in on a
Mac, you'd get a ton of errors because the Mac doesn't support the
Windows libraries. In this case, "portable" means structuring your
code so that the stuff that really is platform-specific is segregated
from the general application logic, so that the general application
logic can be ported easily from one platform to another.

There is no POSIX-specific version of the C language; when people talk
about POSIX C, they're talking about C code that uses interfaces and
utilities defined by the POSIX standard.

Similarly, "Windows C" refers to C code that makes use of interfaces
and utilities specific to the Microsoft Windows platform, although MS
did extend the language a bit (adding extra keywords) to support
Windows programming.
.



Relevant Pages

  • Re: O_TEXT, in microsoft environment
    ... but then C is his language of choice. ... I have since given up on this broken platform, and focus my development efforts on Linux, only occasionally porting stuff to MingW or Cygwin. ... Jacob makes a Windows based C compiler. ...
    (comp.lang.c)
  • Re: There has to be a better way to develop web applications.
    ... one manager still feels VB is not a programmers language, ... learn every tom dick and harry language, standard, and platform so you can ... > the context being discussed all of the arguements are on technology and not ... > on how to use the technology to increase productivity and to provide value to ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: About VS C++
    ... The Free Pascal version has no single memory allocation only static allocated structures and variables. ... I had only a quick look at this single example and I wouldn't call this a serious comparison, beside that the most performant commercial compilers available for Linux aren't in the lists of compared compilers. ... And the discussion here was about .NET on the Windows platform, don't know how performant Mono is compared to .NET. ... The spirit of .NET is>not yet< to replace all native applications and to compile faster code, but language interoperability and productivity - ...
    (borland.public.delphi.non-technical)
  • Re: A C Adventure: your comments are welcome
    ... Most programmers write for Windows. ... language and what parts are specific to the implementation. ... write to it is an error, regardless of platform. ...
    (comp.lang.c)
  • Re: ANSI C compliance
    ... One of the world's most used C compilers, gcc, has a command line ... But it has nothing to do with the C language, ... > platform might not work on another platform. ... Chars have 8 bits and plain char is signed. ...
    (comp.lang.c)