Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Does the 'power' of the C language change with the OS under which it is used ? What exactly is the difference , from a programmer's point of view ?

PS : I want to dive deep into 'C' (Advanced C) and have an affinity towards C under UNIX . Is it better than C under Windows ? Please also comment on creating applications in each environment .

share|improve this question
Define "power". – Oded Nov 10 '12 at 11:30
POSIX: en.wikipedia.org/wiki/POSIX – James Nov 10 '12 at 11:30
@Oded .. power - Ease with which things can be done .. – Appy Nov 10 '12 at 11:32
1  
The language is the same language. You can express your abstractions in a similar way regardless of platform. – Oded Nov 10 '12 at 11:34
4  
@Appy fork() is part of Unix, not part of C. So your question is a bit like: "Is English more powerful in the US or in the UK? I know that they drive on the right side in the US." – Caleb Nov 10 '12 at 13:30
show 2 more comments

closed as not a real question by Oded, Caleb, GlenH7, ChrisF Nov 10 '12 at 16:05

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

2 Answers

up vote 5 down vote accepted

I have listed down into several criteria:

  • The libraries used to get anything platform-specific done are different.
  • Unix world typically will use POSIX syscalls to do system stuff, like IPC etc. Windows isn't POSIX system so it has different API for it.
  • undefined behavior for example, fflush(stdin) doesn't work on Unix
  • data type size (the short=16 bit, int=long=32 bit)
  • carriage return format: in the normal strings it's \n everywhere, but when written on file it's \n on *NIX, \r\n on Windows
  • in particular, pointer size (void * isn't always 32 bit, and can't be always casted safely to an int); in general you should be careful with conversions and comparisons that involve pointers, and you should always use the provided types for that kind of tasks instead of "normal" ints (see in particular size_t and ptrdiff_t)
  • data type "inner format" (the standard do not say that floats and doubles are in IEEE 754, although I've never seen platforms doing it differently);
  • functions (__beginthread, MS safe strings functions; on the other side, POSIX/GNU extensions)
  • compiler extensions (_inline, _declspec, #pragmas, ...) and in general anything that begins with double underscore (or even with a single underscore, in old, nonstandard implementations);
  • console escape codes (this usually is a problem when you try to run Unix code on Windows);

What should You do?

If you're looking for the simplest route to convert from linux/unix to windows, try Cygwin and install the whole boat. It'll make a lot of the headaches go away when you port your code to windows.

The following resources may help you

If you have a good basic regarding Windows & Unix, it will help you

share|improve this answer
@Aaman .. Thanks for the useful answer . What are your views on application development ? Eg - If I want to write the code for a very basic mp3 player , which platform should I choose ? – Appy Nov 11 '12 at 15:27
@Appy, Thanks for comment. It depends on which platform you are used to. And which library has built in libraries regarding your interested field. Code for a very basic mp3 player can be found for Windows and Unix. Happy coding. :) – Mahbubur R Aaman Nov 11 '12 at 15:35
@Aaman .. Thanks for the guidance :) – Appy Nov 11 '12 at 16:10

C standard is the same between these two operating systems. The difference is in the system programming. Traditionnaly, Unix systems are mainly written in C programming langage (cf. Single Unix Specification). Anyway, you can also use API Windows in a C program.

share|improve this answer
Thanks for your answer :) – Appy Nov 10 '12 at 11:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.