GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Sep 30, 2014 10:21 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: using <vector> in GTK project
PostPosted: Fri Apr 20, 2012 3:40 pm 
Offline

Joined: Fri Apr 20, 2012 3:08 pm
Posts: 2
Newber at Linux -running debian squeeze.
Newber at GTK .
Using CodeBlocks GTK+ project

I tried to "#include <vector>" in the project and get --> "error: vector: No such file or directory|"
I've tried <../vector> and other hacks
using namespace std --> error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘namespace’|

#include <vector> --works fine in a console application
I see that GTK includes are installed in /usr/include/gtk-2.0/gdk ---maybe this is wrong

Can <vector> be used in a GTK app?

Thanks in advance


Top
 Profile  
 
 Post subject: Re: using <vector> in GTK project
PostPosted: Fri Apr 20, 2012 5:43 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 750
Location: UK
Hi,

You look like you are getting confused with setting up your IDE. I have no experience with CodeBlocks, although by the sounds of your errors you could be trying to compile your code using a C compiler and not a C++ compiler, hence not being able to include <vector>.

Note doing hacks is not good practice and ends up with very bad code.

Yes it is correct that some of the include files are located in /usr/include/gtk-2.0/gdk. These form part of the GDK library which is some of the lower level window handling and event handling.

Yes <vector> can be used in a GTK application, although your source code must be a C++ source and compiled using a C++ compiler.

_________________
E.


Top
 Profile  
 
 Post subject: Re: using <vector> in GTK project
PostPosted: Fri Apr 20, 2012 6:20 pm 
Offline

Joined: Fri Apr 20, 2012 3:08 pm
Posts: 2
Thanks errol, it was as easy as changing main.c to main.cpp. I'm using gnu gcc as the default compiler. I guess the confusing part was that <vector> worked in console apps. I'm not sure why it defaults to main.c when c++ is selected.

Thanks again, i'm on my way now


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group