Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Dev-C++ and STL compile prob

This thread is locked; no one can reply to it. rss feed Print
Dev-C++ and STL compile prob
Mark Oates
Member #1,146
March 2001
avatar

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?

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

kazzmir
Member #1,786
December 2001
avatar

A)

#include <vector>

b) push_back() needs an argument, no?

hey_there.push_back(1);

23yrold3yrold
Member #1,134
March 2001
avatar

EDIT: What he said. :P

To elaborate on the first one: all standard C++ headers lack file extensions.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

ReyBrujo
Moderator
January 2001
avatar

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 :))

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Mark Oates
Member #1,146
March 2001
avatar

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..

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

23yrold3yrold
Member #1,134
March 2001
avatar

Quote:

a -- if I do that then I get
'vector is used as a type and not defined as a type'

a -- "using namespace std;"? ;)

Quote:

b -- doesn't have to..

b -- yes it does.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

ReyBrujo
Moderator
January 2001
avatar

Hmm... which STL you are using? That is a strange error. And you do need an argument, at least in your version of STL.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Mark Oates
Member #1,146
March 2001
avatar

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 :'(

:P

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

ReyBrujo
Moderator
January 2001
avatar

Do include <vector>, which is what the standard enforces. And do the using namespace std after all includes.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

23yrold3yrold
Member #1,134
March 2001
avatar

Yeah, get that ".h" out of there before things get nasty in here. >:(

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Mark Oates
Member #1,146
March 2001
avatar

oi, thanks alot everybody, it's working now. even though I'll have to rewrite a good portion of my game. :P

Quote:

yeah, get that ".h" out of there before things get nasty in here.

sorry that was a typo.. fixed it.

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

X-G
Member #856
December 2000
avatar

Also, for some reason I forgot exactly it's not recommended to have using namespace std; in headers. Use the explicit namespace specifier there.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

23yrold3yrold
Member #1,134
March 2001
avatar

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.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Go to: