473,387 Members | 1,606 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,387 software developers and data experts.

gcc compile error about vector

HI, when I try the following code, I get a compile error with gcc3.3
under mac OS.

int fill;

struct emp{
int f;
};

#include <vector>

void test(void)
{
std::vector<emp> vt;

vt.resize(2);
}

run 'gcc -x c++ -c -o t.o t.cpp'
gcc can't compile that code.

I'd appreciate any help on this issue.

Nov 30 '05 #1
5 3022
Hu**********@gmail.com wrote:

HI, when I try the following code, I get a compile error with gcc3.3
under mac OS.

int fill;

struct emp{
int f;
};

#include <vector>

void test(void)
{
std::vector<emp> vt;

vt.resize(2);
}

run 'gcc -x c++ -c -o t.o t.cpp'
gcc can't compile that code.

I'd appreciate any help on this issue.


Do you have a more specific error message then that?

--
Karl Heinz Buchegger
kb******@gascad.at
Nov 30 '05 #2
Karl Heinz Buchegger wrote:
Hu**********@gmail.com wrote:

HI, when I try the following code, I get a compile error with gcc3.3
under mac OS.

int fill;

struct emp{
int f;
};

#include <vector>

void test(void)
{
std::vector<emp> vt;

vt.resize(2);
}

run 'gcc -x c++ -c -o t.o t.cpp'
gcc can't compile that code.

I'd appreciate any help on this issue.


Do you have a more specific error message then that?

--
Karl Heinz Buchegger
kb******@gascad.at


I get an error saying (amongst other things).
BTW, I compile the code with gcc3.3 under mac OS10.3(Xcode2.x require
above mac OS10.4, I'm afraid of my machine will be slow if I upgrade to
OS10.4).

error: `fill' is not a function,
/usr/include/g++/bits/stl_algobase.h:561: error: conflict with `void
std::fill(char*, char*, const char&)'

best,

Tony

Nov 30 '05 #3
This was fixed sometime between 3.2.3 & 3.4.4, in the stl_bvector.h &
stl_deque.h, gcc headers were changed from using "fill..." to
"std::fill...".

The problem looks like it's to do with the way the std::vector template
is instantiated, I think this may be a case of ADL not doing what is
expected. If you instantiate a vector of a type that is declared in the
same namespace as "int fill" then it will work fine! In this case
because you are creating std::vector<emp>, when it looks for "fill"
that is used in std::vector it first looks in the global namespace
(where emp is) and then finds "int fill" and gets confused.

So either you need to upgrade or try something like

#define fill std::fill
#include <vector>
#include <deque>
#undef fill

No guarenties mind you. :)

If you don't want to maintain this in the future then wrap this up so
it is disabled once you switch to a newer compiler, as this does break
with the 3.4.4 I have.

Good luck

Nov 30 '05 #4
Hu**********@gmail.com writes:
HI, when I try the following code, I get a compile error with gcc3.3
under mac OS.

int fill;

struct emp{
int f;
};

#include <vector>

void test(void)
{
std::vector<emp> vt;

vt.resize(2);
}

run 'gcc -x c++ -c -o t.o t.cpp'
gcc can't compile that code.

I'd appreciate any help on this issue.


Then you'll have to supply more information. How do you know that
gcc can't compile the code? Perhaps it gave you an error message
that could contain some useful information.

I compiled the code above without any diagnostics on gcc 3.4.2 and
4.1.0. It even worked with the flags -ansi -pedantic -W -Wall.

/Niklas Norrthon
Nov 30 '05 #5
There's a more consise explaination here:
http://www.open-std.org/jtc1/sc22/wg...fects.html#225

Dec 1 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: frankg | last post by:
When I compile this file ------------------------------------------------------ #include <stdarg.h> template <class Any> void var_arg_func(int dimension_count, ...) { int dimensions;...
6
by: bluekite2000 | last post by:
I have Vector<complex<float> > V(5); V.rand(); Vector<float> V1(V); //specialized function here to return norm(V). This works fine Vector<double> V2(5); V2.rand(); Vector<float>...
4
by: George Economos | last post by:
Hi all, I am using msvc 7.1 and have encountered the following code: ----------- A.hpp ----------- class A {
5
by: Carmine Cairo | last post by:
Hi, I'm working on a project and today I've note a little problem during the compile fase. Here a little piece of code: // 1st version welldone = 0; size = p->getSize(); backbone = new...
1
by: ken.carlino | last post by:
Hi, I have the following compile error instantiated from here, I appreciate if someone can help me find out why? g++ -O0 -g3 -Wall -c -fmessage-length=0 -ostddev.o ../stddev.cpp...
1
by: electrixnow | last post by:
Help!, I need to compile this code with static libs so it run on another XP machine that does'nt have MS Studio installed. When I compile now I get an ERROR: 1>------ Rebuild All started:...
5
by: wong_powah | last post by:
#include <vector> #include <iostream> using std::cout; using std::vector; enum {DATASIZE = 20}; typedef unsigned char data_t;
1
by: George2 | last post by:
Hello everyone, Why the below code segment will result in compile error? When I change code to the comment one (constructor), it can compile. The compiler is too stupid? :-) I am using...
3
by: Hill | last post by:
This is an simple map, just an exercise. Who can help me fix this compile issue?Thanks in advance. #include <string> #include <vector> #include <iostream> using std::vector; using std::string;...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.