473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Problem defining vector iterator

I have defined a vector and its iterator as such:
Expand|Select|Wrap|Line Numbers
  1. typedef std::vector< WindsTableElement > WindTable;
  2. WindTable wt_;
  3. WindTable::iterator windIterator_;
I get no errors during compile, but during linking I get:
PPC604gnu/WindDataReceiveBuffer.o(.bss+0x4): multiple definition of `windIterator_'
PPC604gnu/BufferServer.o(.bss+0x0): first defined here
PPC604gnu/WindDataReceiveBuffer.o(.bss+0x8): multiple definition of `wt_'
PPC604gnu/BufferServer.o(.bss+0x4): first defined here
PPC604gnu/WindDataReceiveBuffer.o(.text+0xeec): In function `global constructors keyed to wt_':
: multiple definition of `global constructors keyed to wt_'
PPC604gnu/BufferServer.o(.text+0x15f8): first defined here
PPC604gnu/WindDataReceiveBuffer.o(.text+0xf04): In function `global destructors keyed to wt_':
: multiple definition of `global destructors keyed to wt_'
PPC604gnu/BufferServer.o(.text+0x1610): first defined here
What am I doing wrong?

Thanks in advance.
Jan 29 '07 #1
5 2256
Motoma
3,237 Expert 2GB
I have defined a vector and its iterator as such:
Expand|Select|Wrap|Line Numbers
  1. typedef std::vector< WindsTableElement > WindTable;
  2. WindTable wt_;
  3. WindTable::iterator windIterator_;
I get no errors during compile, but during linking I get:


What am I doing wrong?

Thanks in advance.
It appears that you are linking two .o files which both declare the same variables.
Jan 29 '07 #2
It appears that you are linking two .o files which both declare the same variables.
That's what I would have thought, but a search shows that these variables only show up in one .cpp file.
Jan 29 '07 #3
RedSon
5,000 Expert 4TB
Are you also defining these variables in a matching .h file? If you have delcared them in your .cpp file and then also delcared them in the .h file you have an ambiguous situation, and the complier doesnt like ambiguity.
Jan 29 '07 #4
Are you also defining these variables in a matching .h file? If you have delcared them in your .cpp file and then also delcared them in the .h file you have an ambiguous situation, and the complier doesnt like ambiguity.
Thanks, your analysis was partially right; it set me on the right track. I defined the problem code above the class definition. I moved this:
Expand|Select|Wrap|Line Numbers
  1. WindTable wt_;
  2. WindTable::iterator windIterator_;
  3.  
inside the class definition. The typedef defining WindTable had to remain where it was. I am not sure why, but now it works.
Jan 30 '07 #5
Ganon11
3,652 Expert 2GB
Cool - glad to know it works!
Jan 30 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Dave | last post by:
I'm crossposting this to both comp.lang.c++ and gnu.gcc because I'm not sure if this is correct behavior or not, and I'm using the gcc STL and compiler. When calling vector<int>::push_back(0),...
13
by: Adam Hartshorne | last post by:
Hi All, I was wondering if anybody can tell me what is wrong with the following code, in a .h file I have std::list<std::vector<Site> > positions ; std::list<std::vector<Site> >::iterator...
1
by: Joannes Vermorel | last post by:
I am currently trying to port a small open source scientfic library written in C++ to .Net. The code (including the VS solution) could be found at http://www.vermorel.com/opensource/selfscaling.zip...
2
by: Sherrie Laraurens | last post by:
Hi all, I'm trying to write a generic algorithm routine that will take begin and end iterators of a container, iterate through the range and perform a "calculation" of sorts. The trouble is...
4
by: arnuld | last post by:
i wrote a programme to create a vector of 5 elements (0 to 4), here is the code & output: #include <iostream> #include <vector> int main() { std::vector<intivec; // dynamically create a...
15
by: fungus | last post by:
I'm moving some code from VC++ 6 to VC++ 2005 and I've run into a nasty problem because iterators are no longer pointers. In the program I'm moving, there's a std::vector of items hidden inside...
10
by: StephQ | last post by:
I found that old post: http://groups.google.com/group/comp.lang.c++/browse_frm/thread/3a2562c9a5f8998/15519204726d01e8?lnk=gst&q=vector+no+surprise&rnum=2#15519204726d01e8 I just erased the...
15
by: vivekian | last post by:
Hi, I have this following class class nodeInfo ; class childInfo { public: int relativeMeshId ;
4
by: mkborregaard | last post by:
Hi, I have the weirdest problem, and I can not see what is going wrong. I have made a 2d container class, and am implementing an iterator for that class. However, the ++ operator is behaving very...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.