isascii C99



  • Folgendes Problem:

    #include <stdio.h>
    #include <stdint.h>
    #include <ctype.h>
    
    int main()
    {
    	char z='a' ;
    	if (isascii(z))
    		printf("ist ascci ja\n") ;
    	else
    		printf("ist ascci nein\n") ;
    }
    

    Liefert mir compliert mit:
    gcc -std=c99 -Wall Isascci.c

    folgenden Fehler:
    Isascci.c: In function 'main':
    Isascci.c:9:6: warning: implicit declaration of function 'isascii' [-Wimplicit-function-declaration]
    if (isascii(z))

    Nehme ich aus der Commandozeile --std=c99 heraus, keine Warnung.
    Warum ??



  • Vielleicht gibt es in C99 keine solche Funktion. 💡


  • Mod

    So ist es. Da der TE offenbar keine Manpages lesen kann (sonst hätte er das schließlich selber heraus gefunden):

    man isalpha(3) schrieb:

    Conforming to:

    C89 specifies isalnum(), isalpha(), iscntrl(), isdigit(), isgraph(),
    islower(), isprint(), ispunct(), isspace(), isupper(), and
    isxdigit(), but not isascii() and isblank(). POSIX.1-2001 also
    specifies those functions, and also isascii() (as an XSI extension)
    and isblank(). C99 specifies all of the preceding functions, except
    isascii().

    POSIX.1-2008 marks isascii() as obsolete, noting that it cannot be
    used portably in a localized application.

    POSIX.1-2008 specifies isalnum_l(), isalpha_l(), isblank_l(),
    iscntrl_l(), isdigit_l(), isgraph_l(), islower_l(), isprint_l(),
    ispunct_l(), isspace_l(), isupper_l(), and isxdigit_l().

    isascii_l() is a GNU extension.


Anmelden zum Antworten