473,405 Members | 2,294 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,405 software developers and data experts.

Strange warning with deque.

I'm getting a strange warning at work when I compile any file in our
product that contains a deque of a particular struct. I don't understand
this warning, so I'm not sure if this is a Microsoft Windows issue, or
a C++ issue, so I'm posting it both to a Windows group and to a C++
group.

My OS is Windows 2000, and my compiler is Visual C++ 6.0.

The warning I'm getting is this:

c:\program files\microsoft visual studio\vc98\include\deque(107) :
warning C4146: unary minus operator applied to unsigned type,
result still unsigned
c:\program files\microsoft visual studio\vc98\include\deque(104) :
while compiling class-template member function
'void __thiscall std::deque<struct RT::TempHumData,
class std::allocator<struct RT::TempHumData::const_iterator::_Add(int)'

The problem seems to occur when instantiating std::deque<TempHumArray>.
The problem is with the "_Add()" function in std::deque. For some
reason, it attempts to do a unary minus on a unsigned type:

protected:
void
_Add(difference_type _N)
{
difference_type _Off = _N + _Next - _First;
difference_type _Moff = (0 <= _Off)
? _Off / _DEQUESIZ
: -((_DEQUESIZ - 1 - _Off) / _DEQUESIZ); // WARNING!!!
if (_Moff == 0)
_Next += _N;
else
{
_Map += _Moff;
_First = *_Map;
_Last = _First + _DEQUESIZ;
_Next = _First + (_Off - _Moff * _DEQUESIZ);
}
}

What's this "_Add()" function doing, anyway? To me, it looks like
some kind of pointer arithmetic, possibly implimenting subscripting.

The struct I'm storing in the deque is very simple:

struct TempHumData
{
TempHumData() : TimeStamp(0), Temp(0.0), Hum(0.0), Stage (0) {}
time_t TimeStamp; // VC++6 typedefs "time_t" to "long"
double Temp;
double Hum;
short Stage;
};

The only place where this is put into a deque is in this struct:

struct ZoneRTData
{
// Constructor (default or parameterized)
ZoneRTData (const ::zone& Zone = ::zone())
: Disabled(false), Stage(0), Load(0), DbData(Zone) {}

// Database data:
::zone DbData;

// Zone deadband verification values:
deque<TempHumDataTempHumDeque; // temperature/humidity history deque

// Zone disable/enable control values:
bool Disabled; // zone-disable flag; true if zone is disabled

// ACP/AHP exponential upstage boost control values:
ZoneLoadBoostData ZoneBoost;

// ACP/AHP hysteresis contol values:
short Stage; // historical stage setting...
short Load; // historical load setting...
};

Objects of this type are put in a global map of ZoneRTData objects keyed by
unsigned int object ID numbers.

So... why am I getting this weird "unary minus on unsigned type" warning?
Is this a VC++6.0 thing? Or a C++ thing? Is there something bad I'm
doing in my code that is causing this?
--
Cheers,
Robbie Hatley
Tustin, CA, USA
lonewolfintj at pacbell dot net
(put "[usenet]" in subject to bypass spam filter)
http://home.pacbell.net/earnur/

Jul 4 '06 #1
2 2157
* Robbie Hatley:
>
My OS is Windows 2000, and my compiler is Visual C++ 6.0.
Upgrade to either MSVC 7.1 (free with Visual C++ Toolkit) or MSVC 8.0
(free with Visual Studio Express). Or use some other compiler such as
g++. MSVC 6.0 is very old and does not support template code very well.
Jul 4 '06 #2
"Robbie Hatley" <bo*********@no.spam.comwrote in message
news:vQ********************@newssvr21.news.prodigy .com...
So... why am I getting this weird "unary minus on unsigned type" warning?
Is this a VC++6.0 thing? Or a C++ thing? Is there something bad I'm
doing in my code that is causing this?
The strange warning was added in a service pack, long after the library
code froze. It is indeed just a warning, and a misguided one at that.
The code is correct.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Jul 4 '06 #3

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

Similar topics

16
by: newsock | last post by:
What differences between queue, deque and priority_queue? And under what situations choose one of them to use? Thanks for your help!
7
by: Jenny | last post by:
Hi, I have a class foo which will construct some objects in my code. some of the objects store int values into the data deque, while others store float values to the deque. template <class...
9
by: R.Z. | last post by:
i was wondering whether it pays off in terms of memory use to maintain lots of empty deques (it would be convenient for my algorithms but memory use is more important). and does the size of a deque...
7
by: Dan Trowbridge | last post by:
He everyone, I am just getting started with .NET and I am having a porting problem. I get and error in code that lookssomething like this (really stripped down but you get the idea)... class...
6
by: Peter Oliphant | last post by:
I just discovered that the ImageList class can't be inherited. Why? What could go wrong? I can invision a case where someone would like to add, say, an ID field to an ImageList, possible so that...
5
by: Russell Warren | last post by:
Does anyone have an easier/faster/better way of popping from the middle of a deque than this? class mydeque(deque): def popmiddle(self, pos): self.rotate(-pos) ret = self.popleft()...
5
by: yancheng.cheok | last post by:
after reading http://www.codeproject.com/vcpp/stl/vector_vs_deque.asp, i realize that deque has its own speed advantage over vector in all the aspect (except for memory deallocation). does it...
15
by: Juha Nieminen | last post by:
I'm sure this is not a new idea, but I have never heard about it before. I'm wondering if this could work: Assume that you have a common base class and a bunch of classes derived from it, and...
5
by: meLlamanJefe | last post by:
I have written a Queue class for our use that stores pointers to what I call RequestObjects. RequestObjects are a base class from which other types inherit and this allows the queue (or deque in this...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.