For example, I define AA for three times, is it legal?:
#include
#define AA 10
#define AA 20
#define AA 30
int main() {
printf(\"
No it is not. The C standard clearly states that it is a constraint violation, 6.10.3 p.2:
An identifier currently defined as an object-like macro shall not be redefined by another
#define
preprocessing directive unless the second definition is an object-like macro definition and the two replacement lists are identical.
So as for all constraint violations, your compiler is only obliged to issue a "diagnostic" that is an explanatory message. It may or may not continue to compile your code.
To state it more directly, your code erroneous and your compiler must tell you.