Hello all, I am having a peculiar problem with global variable declarations in a Win32 application. It appears, after a little experimentation, that the first global variable declared in my main .cpp file always shows the same error when the application is built (regardless of what the variable is). The error is as follows: "error: two or more data types in declaration of 'szTitle'".
1 2 3 4 5 6 7 8 9
#include <windows.h>
#define MAX_LOADSTRING 100
char szTitle[MAX_LOADSTRING] = "GoldPhoenix"; // The title bar text
char szClassName[] = "GoldPhoenixWindowsApp"; // Class name text
constint SHIP_MOVE_DELTA = 3; /* How far each ship object will move*/
constint SHOT_MOVE_DELTA = 6; /* How far each shot will move*/
//More variables follow...
No matter what order the variables are declared in (and just as a note, the list of variables goes on, but I don't think listing all the variables matters too much), the same error appears. For instance, if I were to move "cons int SHIP_MOVE_DELTA = 3;" to the first variable declared, the error would read "error: two or more data types in declaration of 'SHIP_MOVE_DELTA'". This is very strange because this variable showed no error before, and then the error concerning szTitle would disappear....
Any information on how to fix this would be much appreciated. And just as one final note, the compiler I'm using is Code::Blocks v. 10.05
You probably typed something by mistake between the top of the file and the first variable declaration (can be somewhere in the included .h files as well). Look better ;-)
Well, to tell the truth, I have an included header called "Classes.h" that actually replaces the <windows.h> and begins as follows:
1 2 3 4 5 6 7
// Classes.h
// To be used for global class definitions used throughout execution
#include <windows.h>
#include "Resource.h"
#include "GoldPhoenix.h"
// Global Class defninitions....
The funny thing is that if I begin my main .cpp file with just #include <windows.h> the error disappears completely.... Unfortunately, after that my global class definitions aren't included, and hence obvious errors occur. Is there anything in the syntax of "Classes.h" that would allow for the original error described above to occur? Just for reference, GoldPhoenix.h is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// GoldPhoenix.h
// Values used by main.cpp
#ifndef IDC_STATIC
#define IDC_STATIC -1
#endif
// Static values used throughout execution
#define HP_S 10 // Not accurate
// Todo: Add values here for enemy HP values and powerups
// Miscellaneous values used throughout execution
#ifndef USER_TIMER_MINIMUM
#define USER_TIMER_MINIMUM 0x0000000A
#endif
You know what, I rebuilt it with #include <windows.h> outside of the "Classes.h" header and it worked.... I still don't know what was going on, but it works now.... Sorry for bothering for such a simple problem...