![]() |
|
Dev-C++ and STL compile prob |
Mark Oates
Member #1,146
March 2001
![]() |
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 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? -- |
kazzmir
Member #1,786
December 2001
![]() |
A) #include <vector>
b) push_back() needs an argument, no? hey_there.push_back(1);
|
23yrold3yrold
Member #1,134
March 2001
![]() |
EDIT: What he said. To elaborate on the first one: all standard C++ headers lack file extensions. -- |
ReyBrujo
Moderator
January 2001
![]() |
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 -- |
Mark Oates
Member #1,146
March 2001
![]() |
a -- if I do that then I get b -- doesn't have to.. ... wait a sec.. -- |
23yrold3yrold
Member #1,134
March 2001
![]() |
Quote: a -- if I do that then I get
a -- "using namespace std;"? Quote: b -- doesn't have to.. b -- yes it does. -- |
ReyBrujo
Moderator
January 2001
![]() |
Hmm... which STL you are using? That is a strange error. And you do need an argument, at least in your version of STL. -- |
Mark Oates
Member #1,146
March 2001
![]() |
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.
-- |
ReyBrujo
Moderator
January 2001
![]() |
Do include <vector>, which is what the standard enforces. And do the using namespace std after all includes. -- |
23yrold3yrold
Member #1,134
March 2001
![]() |
Yeah, get that ".h" out of there before things get nasty in here. -- |
Mark Oates
Member #1,146
March 2001
![]() |
oi, thanks alot everybody, it's working now. even though I'll have to rewrite a good portion of my game. Quote: yeah, get that ".h" out of there before things get nasty in here. sorry that was a typo.. fixed it. -- |
X-G
Member #856
December 2000
![]() |
Also, for some reason I forgot exactly it's not recommended to have using namespace std; in headers. Use the explicit namespace specifier there. -- |
23yrold3yrold
Member #1,134
March 2001
![]() |
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. -- |
|