Espaços nominais
Variantes
Acções

errno

Da cppreference.com
< c‎ | error

 
 
De tratamento de erros
Códigos de erro
Original:
Error codes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Códigos de erro
errno
Afirmações
Original:
Assertions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
Definido no cabeçalho <errno.h>
#define errno /*implementation-defined*/
errno é um pré-processador de macro que se expande para um segmento local modificável lvalue de int tipo. Várias funções de biblioteca padrão indicam erros, por escrito inteiros positivos para errno. Normalmente, o valor de errno está definido para um dos códigos de erro, listados em <errno.h> como constantes macro que começam com a letra E, seguido de letras maiúsculas ou dígitos.
Original:
errno is a preprocessor macro that expands to a thread-local modifiable lvalue of type int. Several standard library functions indicate errors by writing positive integers to errno. Typically, the value of errno is set to one the error codes, listed in <errno.h> as macro constants that begin with the letter E, followed by uppercase letters or digits.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
O valor da errno é 0 na inicialização do programa e, embora as funções da biblioteca é permitido escrever números inteiros positivos para errno ou não um erro, nunca bibliotecas de funções armazenar 0 em errno.
Original:
The value of errno is 0 at program startup, and although library functions are allowed to write positive integers to errno whether or not an error occurred, library functions never store 0 in errno.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Exemplo

#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
 
int main (int argc, char **argv)
{
	int fd = -1;
	fd = open ("/dev/zer0", O_RDONLY);
 
	if (errno)
	{
		perror ("Ouuupsss");
		exit (EXIT_FAILURE);
	}
 
	close (fd);
 
	return EXIT_SUCCESS;
}

Saída:

Ouuupsss: No such file or directory

[editar] Veja também

macros para condições normais POSIX-compatíveis erro
Original:
macros for standard POSIX-compatible error conditions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(macro constante) [edit]
exibe uma seqüência de caracteres correspondente do erro atual para stderr
Original:
displays a character string corresponding of the current error to stderr
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função) [edit]
retorna uma versão do texto de um código de erro apresentado
Original:
returns a text version of a given error code
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(função) [edit]