Home > Back-end >  Why don't redefine an error
Why don't redefine an error

Time:12-05

CodePudding user response:

Why don't redefine an error

CodePudding user response:

.c file

# define _RTC_APP_C_

# include "PCH. H"
#include

Int BBBB.//here defines the PCH. H and defines why not redefine

Int main ()
{


BBBB=9999;
STD: : cout & lt; system("pause");
}

.h files
# # ifndef PCH_H
# define PCH_H
Definition in c # ifdef _RTC_APP_C_//in.
# define _RTC_APP_E_
# the else
# define _RTC_APP_E_ extern
# endif
//why this won't be submitted to redefine the wrong
_RTC_APP_E_ int BBBB.

# endif

CodePudding user response:

Because is the extern

CodePudding user response:

Extern no effect

CodePudding user response:

V is the extern but I still in the KEIL definition

CodePudding user response:

Don't have to struggle the compiler is this serious problem some compilers will not tolerate others
In this just repeat statement you. H file BBBB assignment natural complains, of course, can only say that the compiler is not precise enough tolerance you the small problems

CodePudding user response:

Scope is different, is not the same variable, not wrong

CodePudding user response:

The extern is not without effect?

CodePudding user response:

You try this code won't be an error
Int BBB.
Int main () {
Int BBB.
{
Int BBB.
}
}
Because c + + variable scope under his recent braces

CodePudding user response:

Combined with extern, that is not defined, but a statement,

If global variables are not in the beginning of the file definition, the scope of effective to the end of the file will be restricted to its definition, if before defining point function to reference the global variables, it should be before the reference with keyword extern for the variable "external variable declaration," said the variable is a variable defined external, with this statement, can from the "statement", legally use the external variables
  • Related