Perhaps your file needs to include a header that tells it about the code (that it isn't supposed to have in it if it's a header). [Back to that original order thing, possibly.]
Printable View
Perhaps your file needs to include a header that tells it about the code (that it isn't supposed to have in it if it's a header). [Back to that original order thing, possibly.]
Becaue you are not including windows.h in that file.
Quote:
Originally Posted by prog-bman
YESSSSSSSSSSSSSSSSSS!!!1
YESSS
OH YES, FINALLY! That is why!!! :D :D :D
Ok sorry but finally woot! Sorry, I'm new to C. And I feel stupid now :rolleyes:
heh.
Hmm.. ok lol, new problem now.
It's a little different than before. The difference here is that the compiler is giving me errors when I try to include my global.h file which conains all of my global variables.
Whenver I include:
"global.h"
in the "intro.cpp" file,
it says its already been defined from cosmosII_client.cpp
error:
ect...Code:1>intro.obj : error LNK2005: "int arenaGen" (?arenaGen@@3HA) already defined in cosmosII_client.obj
1>intro.obj : error LNK2005: "int arenaTimeNum" (?arenaTimeNum@@3HA) already defined in cosmosII_client.obj
1>C:\Documents and Settings\Keenan\My Documents\Visual Studio 2005\Projects\CosmosII\Debug\CosmosII.exe : fatal error LNK1169: one or more multiply defined symbols found
But if I take out global.h in the "intro.cpp" file it cant find the variables at all and will say this:
ect... (it doesnt see the variables in global.h!Code:1>.\intro.cpp(109) : error C2065: 'part' : undeclared identifier
1>.\intro.cpp(123) : error C2065: 'diag_1' : undeclared identifier
1>.\intro.cpp(134) : error C2070: ''unknown-type'': illegal sizeof operand
WHAT THE FILES LOOK LIKE:
Code:intro.cpp:
// intro.cpp
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <string.h>
#include <wincon.h>
#include <conio.h>
#include <iostream>
#include <iomanip>
#include "global.h"
#include "color.h"
#include "intro.h"
// prototypes
void main_menu(void); void user_name(void); void difficulty_select(void); void intro(void);
void game_logo(void); void intro_ask(void); void intro_part2(void); void logo(void);
// STARTUP FUNCTIONS:
void logo()
{
dark_logo();system("cls");
for(int intro_loop=0;intro_loop<26;intro_loop++)
{
Sleep(1);
printf("\n\n");
}
} //ect...
global.h:Code:intro.h:
// intro.h
void intro(void);
void game_logo(void);
void intro_ask(void);
void intro_part2(void);
void logo(void);
cosmosII_client.cpp:Code:// global.h
// _________________
// GLOBAL VARIABLES:
extern char diag_1[]="In a galactic system far, far away...";
extern int part=0;
extern char difficultyString[7]="NONE";char typeString[11]="NONE";
extern int difficulty=0,type=0;
//ect...
Code:// COSMOS II - CLIENT (Build 0.00)
/* Coded by X
Begun: April 6, 2006 | End: TBA */
#define _WIN32_WINNT WINVER
// include files
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <string.h>
#include <wincon.h>
#include <conio.h>
#include <iostream>
#include <iomanip>
#include "global.h"
#include "color.h"
#include "intro.h"
#ifdef WIN32
#endif
//ect...
Where are arenaGen and arenaTimeNum defined?
in global.h, like this:
i actually have a lot more...Code:extern int arenaMaxTemp,arenaTemperature,timeGen,arenaWindVariance,arenaLowWind,
arenaMaxWind,arenaWind,arenaTempVariance,arenaLowTemp,arenaFans,arenaForcastNum,
arenaForcastRnd,arenaMaxRange,arenaNum,arenaGen,arenaTimeNum;
EDIT: ignorre spaces i didnt do that
If you declare them as extern, it means they are defined in another file. If you try to define them in the header file, it won't work. So you should have in some header file the variables declared as extern and defined in only one source file, eg:
Code://foo.h
extern int foo;
//foo.cpp
#include "foo.h"
int foo=5; //initialization optional
//main.cpp
#include "foo.h"
int main()
{
std::cout<<foo;
}
hey, hey ,hey that works!