Why do I get this error on locale. h? [Error] expected declaration specifiers or '...' before Numeric Constant

Asked

Viewed 248 times

1

The error ( [Error] expected declaration specifiers or '...' before Numeric Constant ) is pointed out in the

setlocale(LC_ALL, "English");

However, the locale. h library and comma are present and declared in the code earlier, why do I get this error?

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <locale.h>

#ifndef _BIBLIO_H
#define _BIBLIO_H

#include "biblio.h"

#define lim 100
#define prod 500


setlocale(LC_ALL, "Portuguese");

//declarando as funções do programa
void cadastro();
int cad_fornecedor();
int cad_produto();
void menu();
  • 2

    setlocale must be inside a function, probably the main.

1 answer

1


As @anonimo quoted, setlocale() needs to be inside the main(), or some other function, and I speculate that one of the factors below are related to this error.

  • The setlocale(LC_ALL, "C"); be executed before any other user code.

  • And the behavior be undefined when the setlocale() is called some thread, while another thread is running a printf() or even the setlocale() for example.

Browser other questions tagged

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