473,320 Members | 1,694 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,320 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 3019
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.