Specific libraries and standards of C compilers on Windows and Linux

Asked

Viewed 459 times

1

I’d like to know why I know her. h and the strrev() library string.h, not on Linux.

Is there any more that can only be done in Windows? And why does this happen?

Is there any that can only be done on Linux?

I did some research, but in most cases I found very superficial answers.

  • There are many more that are just linux/Unix specifics, and many others that are just windows specifics.

2 answers

2


It doesn’t exist in Windows either. This is not platform specific, it is C implementation, that is, the compiler has a standard library that does not implement this API.

There is a specification of what the C language has, and the implementations must follow it in order to be called C. So the compiler must have a standard library that conforms to the specification. It is true that, in general, it prohibits having anything else, and conio is something else. But usually compilers don’t put too many things in, unless they’re very useful, and very well implemented, which in practice will eventually force you into a new version of the specification. If you don’t come in, you shouldn’t have.

In fact to conio is very bad and should not be used. It was included in a compiler that wanted to have differential and followed by a few others, but those who survived soundly did not do this.

A good Windows compiler like VS-C++, Clang, or Mingw (GCC) does not have conio.

There are several libraries that only work on Windows, or only on Linux, or only on Macos, or only on Android, etc. Even on different distributions of Linux or other Unix-like, or a variant of Windows, not to mention different versions.

But in general we’re talking about platform and non-standard C Apis.

If you need more in-depth answers ask more specific and detailed questions.

0

The library conio.h and the function strrev() library string.h are not part of the standard C. Avoid using them if your purpose is portability.

An alternative implementation of strrev() might be something like:

#include <string.h>
#include <stdio.h>

char * strrev( char * s )
{
    char ch = 0;
    int j = 0;
    int i = strlen(s) - 1;

    while( i > j )
    {
        ch = s[i];
        s[i] = s[j];
        s[j] = ch;
        i--;
        j++;
    }

    return s;
}

int main( void )
{
    char str[] = "O rato roeu a roupa do rei de Roma!";
    printf( "%s\n", strrev( str ) );
    return 0;
}

Exit:

!amoR ed ier od apuor a ueor otar O

Browser other questions tagged

You are not signed in. Login or sign up in order to post.