I'm using Dev-C++ 4.9.8.10 with gcc 3.2
I had some wierd stuff happen with the compiler and managed to get rid of most of it with
-D__GTHREAD_HIDE_WIN32API
-Wno-deprecated
(thanks to the forum search)
but I still have some problems compiling.
#include "allegro.h" #include <vector.h> vector<int> hey_there; int main() { hey_there.push_back(); allegro_init(); allegro_message("punkazz"); } END_OF_MAIN();
I get the errors:
C:\Documents and Settings\Mark\Desktop\The Stuff\programming\C - C++\Trying a new project\main.cpp [Warning] In function `int _mangled_main()': 9 C:\Documents and Settings\Mark\Desktop\The Stuff\programming\C - C++\Trying a new project\main.cpp no matching function for call to `std::vector<int, std::allocator<int> >::push_back()' 9 C:\Documents and Settings\Mark\Desktop\The Stuff\programming\C - C++\Trying a new project\main.cpp no matching function for call to `std::vector<int, std::allocator<int> >::push_back()' 9 C:\Documents and Settings\Mark\Desktop\The Stuff\programming\C - C++\Trying a new project\main.cpp no matching function for call to `std::vector<int, std::allocator<int> >::push_back()'
eh?
A)
#include <vector>
b) push_back() needs an argument, no?
hey_there.push_back(1);
EDIT: What he said.
To elaborate on the first one: all standard C++ headers lack file extensions.
Don't you need to put a value into the push? A number, in example, since your vector is made of integers?
(Edited: It feels nice to be beaten along with 23 )
a -- if I do that then I get
'vector is used as a type and not defined as a type'
b -- doesn't have to..
... wait a sec..
a -- if I do that then I get
'vector is used as a type and not defined as a type'
a -- "using namespace std;"?
b -- doesn't have to..
b -- yes it does.
Hmm... which STL you are using? That is a strange error. And you do need an argument, at least in your version of STL.
aha! it works now.
#include "allegro.h" using namespace std; #include <vector> vector<int> hey_there; int main() { hey_there.push_back(1); allegro_init(); allegro_message("I hate it when you're right"); } END_OF_MAIN();
I'll have to go back and change all the push_back()s. I didn't have to have a value with the last gcc 2.95.3-6.
why was I mislead for so long... .nooooooo
Do include <vector>, which is what the standard enforces. And do the using namespace std after all includes.
Yeah, get that ".h" out of there before things get nasty in here.
oi, thanks alot everybody, it's working now. even though I'll have to rewrite a good portion of my game.
yeah, get that ".h" out of there before things get nasty in here.
sorry that was a typo.. fixed it.
Also, for some reason I forgot exactly it's not recommended to have using namespace std; in headers. Use the explicit namespace specifier there.
That isn't a header file.
And the reason it's bad practice is that you pollute the global namespace for any file you then later include that header in. The explicit namespace specifier should be used in headers, and whatever the heck you feel like using in source files.