Okay I'm damn fed up with this problem ever since I've been trying to organize a bunch of global variables and functions. I'm organizing the variable/function declarations in a header file and defining them in a separate cpp file. So, Globals.h and Globals.cpp.. I then try and link this both to my main.cpp and my Rabbit.h (which is a custom class I'm making that requires those variables)...I have the header guards and the #pragma once thing... What am I doing wrong? PLEASE HELP! I cannot stand this error anymore.. How should I organize global information and have it not multiply defined?
ichigo_cool
-4
Junior Poster
Recommended Answers
Jump to PostPlease post the code that you have right now.
Jump to PostIt isn't hard to see where the problem lies, now that we've seen the code. What's going on is that you declare the variables and define several functions in the header itself; this becomes a problem when you then #include said header in more than one compilation unit. To get …
Jump to PostThanks a ton! That worked perfectly.. however now there is the issue of declaring a variable without defining it - this gives me the same multiply defined error...
I declare SDL_Event event; in the header file and when I do not define it I get the error, because it is …
All 10 Replies
NathanOliver
429
Veteran Poster
Featured Poster
ichigo_cool
-4
Junior Poster
NathanOliver
429
Veteran Poster
Featured Poster
Schol-R-LEA
1,446
Commie Mutant Traitor
Featured Poster
ichigo_cool
-4
Junior Poster
mrnutty
761
Senior Poster
ichigo_cool
-4
Junior Poster
mrnutty
761
Senior Poster
Schol-R-LEA
commented:
Why oh why didn't I think to ask that?
+7
ichigo_cool
-4
Junior Poster
mrnutty
761
Senior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.