Posts: 2,593
Threads: 34
Joined: Dec 2007
Can someone explain me why this not works?
top
init
SetTimer
pawn Код:
public Show()
{
if(array)
{
#if !defined SOMETHING
#define SOMETHING
#endif
print("Defined");
}else{
#if defined SOMETHING
#undef SOMETHING
#endif
print("Undefined");
}
#if defined SOMETHING
print("Defined :D");
#else
print("Not defined :D");
#endif
return 1;
}
Shows
Defined
Not defined
Defined
Not defined
Defined
Not defined
Defined
Not defined
...
Posts: 1,741
Threads: 44
Joined: Apr 2010
Reputation:
0
Pretty self explained the way i see it.
new array;
new array = 1;
__________________________________
1. Checks if SOMETHING is defined.
2. defines if SOMETHING isn't defined
3. Prints "Defined"
4. Checks if SOMETHING is defined.
5. undefines SOMETHING if it's defined.
6. prints "Undefined"
Posts: 704
Threads: 118
Joined: Sep 2010
Reputation:
0
#define text (1)
than
#if text (1) (or 0) .. your func #endif
Posts: 2,593
Threads: 34
Joined: Dec 2007
19.10.2010, 17:44
(
Последний раз редактировалось Jefff; 19.10.2010 в 18:06.
)
Quote:
Originally Posted by Gh0sT_
#define text (1)
than
#if text (1) (or 0) .. your func #endif
|
So i've undefined symbol SOMETHING
this #define SOMETHING 1 must be on top not in ;x
>>> HELP <<<
Posts: 2,593
Threads: 34
Joined: Dec 2007
Quote:
Originally Posted by g_aSlice
|
Nothing usefull
Posts: 2,593
Threads: 34
Joined: Dec 2007
ok none knows, so delete please this topic and thx for none help
Posts: 4
Threads: 0
Joined: Oct 2010
Reputation:
0
You are using the syntax on a wrong way, on a very suspicious wrong way -_-
You first check if it SOMETHING is defined, if it is NOT defined, you define it, than you check if SOMETHING is defined, if it is defined, you undefine it. You are repeating the syntax/function all the time which causes the prints. On a easier way to explain it to you, I will make it in steps:
1. You check if SOMETHING is not defined
2. If it is not defined, you define it
3. Then below it checks if SOMETHING is defined, if it is, than you undefine it
4. The syntax (#if !defines SOMETHING) on the top cheks if it is not defined
5. The last check undefined it, but the syntax on the top checks if it is not defined, if it is not, it defines again.
Sorry if it is quite difficult, I couldn't explain it on an easier way. In a line: The function/syntax you made is an endless process
Posts: 2,593
Threads: 34
Joined: Dec 2007
I know what am doing ;x i am not a noob.
i run forst time timer so array == 1 and
pawn Код:
#if !defined SOMETHING
#define SOMETHING
#endif
SOMETHING is NOT defined so I #define and next is
pawn Код:
#if defined SOMETHING
print("Defined :D");
#else
print("Not defined :D");
#endif
yes i define so must print
but prints
why this works only here
pawn Код:
if(array)
{
#if !defined SOMETHING
#define SOMETHING
#endif
print("Defined");
}
but not here
pawn Код:
#if defined SOMETHING
print("Defined :D");
#else
print("Not defined :D");
#endif
too
Posts: 2,593
Threads: 34
Joined: Dec 2007
OMG so great
pawn Код:
public Show()
{
if(array)
{
#if !defined SOMETHING
#define SOMETHING
print("Defined");
#endif
}else{
#if defined SOMETHING
#undef SOMETHING
print("Undefined");
#endif
}
#if defined SOMETHING
print("Defined :D");
#else
print("Not defined :D");
#endif
return 1;
}
then why not prints
Defined
Undefined
Not defined
?
Posts: 2,593
Threads: 34
Joined: Dec 2007
Lol very very... stupid, ok thx 4 explaining, solved