PDA

View Full Version : [SOLVED] ‘not’ undeclared, WTF!?



crazyfuturamanoob
December 2nd, 2008, 04:54 PM
Why I get this error?


stuff.c:40: error: ‘not’ undeclared (first use in this function)

not does not exist!? Huh? How can I fix this?

And also, why don't and & xor work either?

I have to use && and ^, why? Can't I use the words? That would make code more readable.

FaresH
December 2nd, 2008, 04:58 PM
What language are you using ?

If its c and c++, not is !

example :



isTrue = true;

if( isTrue )
// What ever
}

is similar to




isTrue=false;

if( !(isTrue) ){
// What ever
}

crazyfuturamanoob
December 2nd, 2008, 05:10 PM
Always forgot, it's C.

But why Scite highlights NOT, AND & XOR and some other stuff when they don't exist?

nvteighen
December 2nd, 2008, 06:09 PM
Well, why don't you try using a macro:


#define not !


This should work for most cases, I guess.

gvoima
December 2nd, 2008, 06:11 PM
Always forgot, it's C.

But why Scite highlights NOT, AND & XOR and some other stuff when they don't exist?

If you have C syntax highlighting enabled, it should not highlight not, and or xor?

crazyfuturamanoob
December 2nd, 2008, 06:27 PM
If you have C syntax highlighting enabled, it should not highlight not, and or xor?

Scite highlights these things, but they aren't declared automatically:

not
xor
and
or
false
true

And probably some others too but I'm not sure if I remembered everything.

Paul Miller
December 2nd, 2008, 06:55 PM
I'd like to suggest that you use ! rather than the word "not," when writing C code. Sure, you can do


#define not !

but that's bad practice, and it's going to end up making the code *less* readable to anyone with even a passing familiarity with C. So, just don't do it.

As for why Scite wants to highlight those things, I don't have a clue.

jespdj
December 2nd, 2008, 09:47 PM
Scite highlights these things, but they aren't declared automatically:
not, xor, and, or: These are not keywords in C nor are they standard functions or macros. Just because Scite highlights these things, doesn't mean they exist.

I don't use Scite, but is it maybe highlighting for a different programming language than C? Look if Scite is set correctly.

mike_g
December 2nd, 2008, 10:10 PM
It may be because not and xor are reserved words in C++:
http://cs.stmarys.ca/~porter/csc/ref/cpp_keywords.html
So, if you want your code to be usable by C++ progs you might want to avoid using these words as identifiers.

jimi_hendrix
December 2nd, 2008, 10:27 PM
my little 2 cents...

just a reminder for the future in C bool is not a type...you have to include bool.h and yes you must use && and ||...

crazyfuturamanoob
December 3rd, 2008, 12:13 PM
not, xor, and, or: These are not keywords in C nor are they standard functions or macros. Just because Scite highlights these things, doesn't mean they exist.

I don't use Scite, but is it maybe highlighting for a different programming language than C? Look if Scite is set correctly.

My scite highlight option is "C/C++". And as other ppl have mentioned, maybe those words are reserved in C++?