What's wrong with my integer declaration?

Hello,

When I tried compiling a simple program I had written, I got the error message "Badly formed expression" in reference to an integer variable declaration "int F_TEST". I couldn't understand why this was happening. I even tried the declaration on its own like this:

1
2
3
4
5
6
int main () {

int F_TEST;

return 0;
}


I still get the error message "Badly formed expression." I don't necessarily have to give my integer variable this name but why is this happening?

Thanks.
You did give F_TEST a value and compiler is still waiting for the value of F_TEST. It is a good Idea to give every variable a value (A value of zero is good) to avoid this problem and many others.
There has to be more to it than that. Is F_TEST a macro or something?
You did give F_TEST a value and compiler is still waiting for the value of F_TEST. It is a good Idea to give every variable a value (A value of zero is good) to avoid this problem and many others.


In my experience, I've always been able to declare ints without assigning them values, so that can't be the problem (although it is good practice to assign values on the same line of initialization).

I ran the code on my computer and got error: expected unqualified-id before numeric constant
The code ran perfectly when I replaced F_TEST with any other name.

My guess is that F_TEST is some obscure keyword in the language that you are not allowed to use for naming things.
Do you have any more code? What IDE/compiler are you using? I can compile that code with no errors on VC++2008.
closed account (DSLq5Di1)
It is possible that F_TEST is defined in a header you've included, such as:-
http://pubs.opengroup.org/onlinepubs/007908799/xsh/lockf.html
Interesting. I just ran a couple variations of the code on Ubuntu's g++ compiler.

It turns out if you run it with no headers, it works fine.
However, if you write #include<iostream>, you get an error, so F_TEST must be defined in iostream as well as in unistd.h (as mentioned by sloppy9).
Topic archived. No new replies allowed.