Archives
D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger
C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows
digitalmars.empire
digitalmars.DMDScript
|
c++ - "count" defined behind the scenes, name conflict...
↑ ↓ ← → dan <dan_member pathlink.com> writes:
Not sure if this comes from DM, stlport, or what. I accidentally used a variable
count, which I planned to, but forgot to declare, and got the worrisome error
message below:
sc main.cpp -cpp -Ae -Ar -r -mn -C -WA -S -3 -a8 -c -gf -D_DEBUG=1 -D_CONSOLE=1
-IG:\dm\stlport\stlport -IG:\dm\include -IG:\boost-1.30.2
-IG:\boost-1.30.2\boost -omain.obj
Error: G:\BACNET\RS485\TEST\main.cpp(119): need explicit cast for function
parameter 3 to get
G:\BACNET\RS485\TEST\main.cpp(119): from: difference_typeiterator_traits<>(*C
func)(_InputIter,_InputIter,const _Tp&)
G:\BACNET\RS485\TEST\main.cpp(119): to : unsigned long *
Lines Processed: 147315 Errors: 1 Warnings: 0
Build failed
↑ ↓ ← → Scott Michel <scottm cs.ucla.edu> writes:
And the offending code looks like?
dan wrote:
Not sure if this comes from DM, stlport, or what. I accidentally used a
variable count, which I planned to, but forgot to declare, and got the
worrisome error message below:
sc main.cpp -cpp -Ae -Ar -r -mn -C -WA -S -3 -a8 -c -gf -D_DEBUG=1
-D_CONSOLE=1 -IG:\dm\stlport\stlport -IG:\dm\include -IG:\boost-1.30.2
-IG:\boost-1.30.2\boost -omain.obj
Error: G:\BACNET\RS485\TEST\main.cpp(119): need explicit cast for function
parameter 3 to get
G:\BACNET\RS485\TEST\main.cpp(119): from:
difference_typeiterator_traits<>(*C func)(_InputIter,_InputIter,const
_Tp&)
G:\BACNET\RS485\TEST\main.cpp(119): to : unsigned long *
Lines Processed: 147315 Errors: 1 Warnings: 0
Build failed
↑ ↓ ← → dan <dan_member pathlink.com> writes:
In article <burnq9$vjj$1 digitaldaemon.com>, Scott Michel says...
And the offending code looks like?
//like this:
#include <iostream>
#include <tchar.h>
#include <windows.h>
#include <crtdbg.h>
#include <string.h>
....................
z.Read(b,10,&count);
//where "count" is not defined (by me, anyhow).
sc main.cpp -cpp -Ae -Ar -r -mn -C -WA -S -3 -a8 -c -gf -D_DEBUG=1
-D_CONSOLE=1 -IG:\dm\stlport\stlport -IG:\dm\include -IG:\boost-1.30.2
-IG:\boost-1.30.2\boost -omain.obj
Error: G:\BACNET\RS485\TEST\main.cpp(119): need explicit cast for function
parameter 3 to get
G:\BACNET\RS485\TEST\main.cpp(119): from:
_Tp&)
G:\BACNET\RS485\TEST\main.cpp(119): to : unsigned long *
Lines Processed: 147315 Errors: 1 Warnings: 0
Build failed
↑ ↓ ← → Scott Michel <scottm cs.ucla.edu> writes:
I understand your problem, but really, can you give a short example without
the "...."'s? What is z's type, for example?
dan wrote:
In article <burnq9$vjj$1 digitaldaemon.com>, Scott Michel says...
And the offending code looks like?
//like this:
#include <iostream>
#include <tchar.h>
#include <windows.h>
#include <crtdbg.h>
#include <string.h>
....................
z.Read(b,10,&count);
//where "count" is not defined (by me, anyhow).
sc main.cpp -cpp -Ae -Ar -r -mn -C -WA -S -3 -a8 -c -gf -D_DEBUG=1
-D_CONSOLE=1 -IG:\dm\stlport\stlport -IG:\dm\include -IG:\boost-1.30.2
-IG:\boost-1.30.2\boost -omain.obj
Error: G:\BACNET\RS485\TEST\main.cpp(119): need explicit cast for
function parameter 3 to get
G:\BACNET\RS485\TEST\main.cpp(119): from:
_Tp&)
G:\BACNET\RS485\TEST\main.cpp(119): to : unsigned long *
Lines Processed: 147315 Errors: 1 Warnings: 0
Build failed
↑ ↓ ← → dan <dan_member pathlink.com> writes:
In article <burplb$12kr$1 digitaldaemon.com>, Scott Michel says...
I understand your problem, but really, can you give a short example without
the "...."'s? What is z's type, for example?
z's type is CSerial, and it's a big class for wrapping serial port
communication; but I really don't think the problem comes from there, as that
serial library is rather oldish and doesn't make use of stl, iterators or
traits.
My code is using std::pair<> and std::list<>; though I'm also using boost's MPL
library; but the 'count' the error message refers to looks more stl'ish than
boost'ish to me; though I've been wrong before...
Besides, it's not like I'm saying "z.count"... just "count".
I can send you a zip with all the sources if you like, but I don't think it
would help. Seems to me one of the headers must be defining count in global
space, (which seems crazy to me...).
↑ ↓ ← → Scott Michel <scottm cs.ucla.edu> writes:
Actually, Dan, I don't fix compiler bugs, DigitalMars' Walter does that. (*)
What I was merely pointing out was that for this particular bug to get
fixed, you might want to boil it down the simplest form of code possible. I
was merely trying to nudge you in the right direction.
It also may just be that the error message is confusing or inappropriate.
There may be another template whose third param is an unsigned long; in the
absense of any other information, DMC++ is assuming that the closest
matching template is the one whose third param is an unsigned long. That'd
be my guess.
If the error message is actually confusing, then you'll still need a short
example code snippet to demonstrate and propose a fix.
-scooter
(*) I wish I had access to the source to help with improving/fixing bugs and
the IDDE. But Christmas isn't for another year.
dan wrote:
In article <burplb$12kr$1 digitaldaemon.com>, Scott Michel says...
I understand your problem, but really, can you give a short example
without the "...."'s? What is z's type, for example?
z's type is CSerial, and it's a big class for wrapping serial port
communication; but I really don't think the problem comes from there, as
that serial library is rather oldish and doesn't make use of stl,
iterators or traits.
My code is using std::pair<> and std::list<>; though I'm also using
boost's MPL
library; but the 'count' the error message refers to looks more stl'ish
than
boost'ish to me; though I've been wrong before...
Besides, it's not like I'm saying "z.count"... just "count".
I can send you a zip with all the sources if you like, but I don't think
it would help. Seems to me one of the headers must be defining count in
global space, (which seems crazy to me...).
↑ ↓ ← → dan <dan_member pathlink.com> writes:
There may be another template whose third param is an unsigned long; in the
absense of any other information, DMC++ is assuming that the closest
matching template is the one whose third param is an unsigned long. That'd
be my guess.
No, look at the message again: My function expected a pointer to an unsigned
long, but I forgot to declare "unsigned long count". So, what would the
compiler normally do? It would say "count not declared". *Instead*, it says
that it cannot convert "count", in whatever screwey way it IS ALREADY DEFINED
SOMEWHERE, to a pointer to an unsigned long.
But why should there be ANYTHING named "count"?!?!... especially in global
space!!! Maybe "____COUNT____", but not "count"!!!
Cheers!
↑ ↓ ← → Arjan Knepper <arjan ask.me> writes:
dan wrote:
There may be another template whose third param is an unsigned long; in the
absense of any other information, DMC++ is assuming that the closest
matching template is the one whose third param is an unsigned long. That'd
be my guess.
No, look at the message again: My function expected a pointer to an unsigned
long, but I forgot to declare "unsigned long count". So, what would the
compiler normally do? It would say "count not declared". *Instead*, it says
that it cannot convert "count", in whatever screwey way it IS ALREADY DEFINED
SOMEWHERE, to a pointer to an unsigned long.
But why should there be ANYTHING named "count"?!?!... especially in global
space!!! Maybe "____COUNT____", but not "count"!!!
Cheers!
Arjan
↑ ↓ ← → dan <dan_member pathlink.com> writes:
Are you sure you don't have "auto prototype" turned on?
Don't even know what it is...
↑ ↓ ← → Arjan Knepper <arjan ask.me> writes:
dan wrote:
Are you sure you don't have "auto prototype" turned on?
Don't even know what it is...
In the IDDE you are able to set the option for (C) function prototyping,
a missing prototype will be automagically added on first use/call of the
function.
IDDE: See project -> Setting -> Build-tab -> Prototype
CMDline -p-
Arjan
↑ ↓ ← → dan <dan_member pathlink.com> writes:
Don't even know what it is...
a missing prototype will be automagically added on first use/call of the
function.
IDDE: See project -> Setting -> Build-tab -> Prototype
CMDline -p-
I hadn't even noticed that option... No, in fact, I had set it to 'strict'.
↑ ↓ ← → Scott Michel <scottm cs.ucla.edu> writes:
Speaking of reading carefully, maybe you should carefully reread my message.
I never disagreed that the error message is misleading or inaccurrate.
Unless you can track down where "count" is declared, the only other
explanation is a misleading error message.
Having built a compiler or two before I came back to gradual school, I know
how easy it is for a compiler to generate a bad, inaccurrate, inoperative,
misleading, outright incorrect error message.
Proove me wrong and find where "count" is declared as a variable and
buttress your assertion.
-scooter
dan wrote:
There may be another template whose third param is an unsigned long; in
the absense of any other information, DMC++ is assuming that the closest
matching template is the one whose third param is an unsigned long. That'd
be my guess.
No, look at the message again: My function expected a pointer to an
unsigned
long, but I forgot to declare "unsigned long count". So, what would the
compiler normally do? It would say "count not declared". *Instead*, it
says that it cannot convert "count", in whatever screwey way it IS ALREADY
DEFINED SOMEWHERE, to a pointer to an unsigned long.
But why should there be ANYTHING named "count"?!?!... especially in global
space!!! Maybe "____COUNT____", but not "count"!!!
Cheers!
↑ ↓ ← → dan <dan_member pathlink.com> writes:
In article <bv1aoo$j4j$1 digitaldaemon.com>, Scott Michel says...
Speaking of reading carefully, maybe you should carefully reread my message.
I never disagreed that the error message is misleading or inaccurrate.
Unless you can track down where "count" is declared, the only other
explanation is a misleading error message.
Sorry, wouldn't have thought of a misleading error message, yet I don't see
where were you suggesting that in your message; but maybe I'm misreading it.
You mentioned a template foulup leading to expecting a pointer to a long; but
what I was trying to say is that my function already expects a pointer to a
long, so there's no need to find *why* a ptr to long would be needed. It's
supposed to be needed. It's not that I passed a pointer to long by accident,
but rather that I was passing a pointer to a long called "count" which I never
declared. Anyways, I changed the name to "coun", and declared it, and
everything's running smoothly. But I thought I'd report the fact that someone or
something is apparently declaring something called "count".
Having built a compiler or two before I came back to gradual school, I know
how easy it is for a compiler to generate a bad, inaccurrate, inoperative,
misleading, outright incorrect error message.
Proove me wrong and find where "count" is declared as a variable and
buttress your assertion.
Hmm, wouldn't know where to start, and I'm really behind schedule with my
project. I guess I'll prove you wrong in a week or two... ;-)
↑ ↓ ← → Scott Michel <scottm cs.ucla.edu> writes:
dan wrote:
Sorry, wouldn't have thought of a misleading error message, yet I don't
see
where were you suggesting that in your message; but maybe I'm misreading
it.
You mentioned a template foulup leading to expecting a pointer to a long;
but what I was trying to say is that my function already expects a pointer
to a long, so there's no need to find *why* a ptr to long would be needed.
It's
supposed to be needed. It's not that I passed a pointer to long by
accident, but rather that I was passing a pointer to a long called "count"
which I never declared. Anyways, I changed the name to "coun", and
declared it, and everything's running smoothly. But I thought I'd report
the fact that someone or something is apparently declaring something
called "count".
There are a few places in STLport where a "count" occurs, using the magic of
Cygwin utilities and "grep -n -r count stlport | grep -v _count":
stl/_algo.h, line 125
stl/_algobase.h, line 524
stl/_fstream.h, line 113
stl/_hashtable.h, line 501
stl/_hash_map.h, lines 191, 380
stl/_hash_set.h, lines 191, 388
You're not seeing a misleading error message. It's the compiler trying to
match up a template function named "count" that counts the number of
elements between two iterators, first and list, that match a particular
value.
You might want to go off an have a word with the HP and SGI STL folks, as
well as the STLport folks for having a template function named "count".
Finding this wasn't that hard. :-)
-scooter
↑ ↓ ← → dan <dan_member pathlink.com> writes:
You might want to go off an have a word with the HP and SGI STL folks, as
well as the STLport folks for having a template function named "count".
I'll report it to stlport; thanks!
Finding this wasn't that hard. :-)
Newbie here ;-)
↑ ↓ ← → Scott Michel <scottm cs.ucla.edu> writes:
dan wrote:
You might want to go off an have a word with the HP and SGI STL folks, as
well as the STLport folks for having a template function named "count".
I'll report it to stlport; thanks!
Finding this wasn't that hard. :-)
Newbie here ;-)
I don't think you want to be too hasty on that report. The count template
function is actually a feature. :-) :-) :-)
-scooter
↑ ↓ ← → "Walter" <walter digitalmars.com> writes:
"Scott Michel" <scottm cs.ucla.edu> wrote in message
news:bv4qs9$9cu$1 digitaldaemon.com...
I don't think you want to be too hasty on that report. The count template
function is actually a feature. :-) :-) :-)
I have a lot of experience tracking down strange problems happening with
vast, over complicated, excessively interrelated, layered huge masses of
source code. It just never works to guess at what is going on. The only
thing to do is to follow the advice at www.digitalmars.com/faq.html#error
and www.digitalmars.com/bugs.html
There really isn't any other way that works.
|
|