|
could you show the code that's crashing please ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Sorry its just a compiler Warning, but was trying to get rid of it.
I have a structure:-
typedef struct <br />
{<br />
char scaling [SCALE_LENGTH];<br />
char format [FORMAT_LEN];<br />
char dataRaw [DATA_LEN];<br />
char dataEng [DATA_LEN];<br />
char display1 [DISPLAY_LEN];<br />
int base;<br />
int offset;<br />
int mask;<br />
int wordSize;<br />
int shift;<br />
int noFieldsBefore;<br />
int noFieldsAfter;<br />
double maximum;<br />
double minimum;<br />
double fullScale;<br />
}SIGNAL_DETAILS;<br />
<br />
And init:-<br />
<br />
SIGNAL_DETAILS signal_details[NO_FIELDS] = {<br />
"1",
"Integer",
"0",
"0",
"%04X",
382,
0,
-2147483648, <br />
32,
0,
0,
3,
255.000000 ,
0.000000 ,
255.000000 ,
,<br />
etc.
Its the Initialisation of mask to -2147483648 that causes the problem.
|
|
|
|
|
why you are assigning value to an int,which falls out of its range?
|
|
|
|
|
it is not out of range, it is exactly the lower bound of a 32-bits signed int :
2^32 = 4294967296
(2^32)/2 = 2147483648
so, signed int contains values into [-2147483648 ; +2147483647]
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
oops ! my mistake.
just careless reading.
|
|
|
|
|
How about :
{
char scaling [SCALE_LENGTH];
char format [FORMAT_LEN];
char dataRaw [DATA_LEN];
char dataEng [DATA_LEN];
char display1 [DISPLAY_LEN];
int base;
int offset;
signed int mask;
int wordSize;
int shift;
int noFieldsBefore;
int noFieldsAfter;
double maximum;
double minimum;
double fullScale;
}SIGNAL_DETAILS;
~RaGE();
|
|
|
|
|
Still the same compiler warning.
|
|
|
|
|
ok, i've got it... just have a look at the MSDN[^] :
Practically, this occurs when the programmer is trying to express the minimum integer value, which is -2147483648. This value cannot be written as -2147483648 because the expression is processed in two stages:
1. The number 2147483648 is evaluated. Because it is greater than the maximum integer value of 2147483647, the type of 2147483648 is not int, but unsigned int.
2. Unary minus is applied to the value, with an unsigned result, which also happens to be 2147483648.
ah, that was so simple
just use INT_MIN instead of hard coding the value and don't forget to #include<limits.h>...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I tried 0x8000000 and it worked OK.
But thanks for your post.
|
|
|
|
|
What compiler are you using? Are you building for Win32?
'int' is per definition signed and the range of the type is –2,147,483,648 to 2,147,483,647 in a 32-bit environment.
What happens if you change the radix of the value to hex and assign 0x80000000?
(Since this looks like a bit mask perhaps this is preferred anyway...)
--
Roger
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
typedef struct MyTag {...} MyStruct;<br />
MyStruct MyArray[MYSIZE] = { {...}, {...}, etc.. };
Notice the embeded "{...}", each of these represent a seperate struct item in the array.
I suspect that because you are not doing this, each of the items that you enter (seperated by a ',') may be considered initialization of seprate item structures. I could be wrong about this, but I have seen this type of error many in my career, and the solution has always been the same.
INTP
Every thing is relative...
|
|
|
|
|
|
how does components like DAO, ADO etc (for example) are made? is it through ATL?
in ATL we set or get properties like ,
Obj.Value (single . [dot])
but how to make things like
[vb]
dim rs as recordset
rs.fields.count
[/vb]
Here we have two 'dots'.. is it through passing structures ? or what DS?
i want to do like,
Obj.Values.count
how do i get the .cout after .Values?
Thanks
He is like a one-legged man in a bum kicking competition. -Novjot Sidhu
--[v]--
|
|
|
|
|
you'll have a .count only if the .Values object is of a type that provides a count method.
moreover, vb is bad in that fact that properties don't always need parenthesis (() ) when they are called ; i find this obfuscates the code...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
mmmm..ok but is it possible to pass a C++ object to a VB Client thru 'methods'?
toxcct wrote: vb is bad in that fact that properties don't always need parenthesis (()) when they are called ; i find this obfuscates the code...
ya i'm an x-vb programmer, and i still use it for Client Applications that use COM, but i really dont like it , though i find C++ a bit tougher , Satisfaction is really great.
He is like a one-legged man in a bum kicking competition. -Novjot Sidhu
--[v]--
-- modified at 6:46 Wednesday 19th October, 2005
|
|
|
|
|
VivekuniQ wrote: is it possible to pass a C++ object to a VB Client thru 'methods'?
What do you mean ? You cannot have a C++ object into VB (like that I mean, you can use techologies like COM but that's another thing) so how do you want to make it pass thru methods ??
Maybe you are speaking about COM objects ? I don't really understand what you want to achieve...
|
|
|
|
|
|
so how was your day yesterday?? Boozing ?? u take Beer or Wine.. tu est un francais et donc je pense que tu prefere la vin?? anyway howz my french buddy??
He is like a one-legged man in a bum kicking competition. -Novjot Sidhu
--[v]--
|
|
|
|
|
VivekuniQ wrote: so how was your day yesterday??
hum, yeasterday was nice, but calm... actually, no beer, no party, nothing at all, for the only reason that i'm alone during the week, so everything will start on friday evening...
VivekuniQ wrote: tu est un francais et donc je pense que tu prefere le vin??
humm, you shouldn't generalize..., yeah, i'm french, i'm proud of some good french products, but i'm in fact not a great fan a alcoholized drinks... i drink a bit on a party, but never alone, and never too much.
anyway, i'm fine today thanks for caring
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I always have a high regard for france and the french people.. .. Cool language,cool country, cool people
He is like a one-legged man in a bum kicking competition. -Novjot Sidhu
--[v]--
|
|
|
|
|
humm, i think not everybody think like you
i don't care... there are stupid people everywhere, even in France !!! lol
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
U make the Web page colour full
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
at about 1 year and a half, yeah, i was the almost only one to colorize the forums, but a piece of months later, alok came to CodeProject and started adding some blue to the pages. now, we are a several ones to have personalized our nick...
so, yes the forums are colorfull, but i'm not the only one
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote: a piece of months later, alok came to CodeProject and started adding some blue to the pages
A Piece .. i already spent almost year and half here
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
toxcct wrote: VivekuniQ wrote:
tu es un francais et donc je pense que tu prefere le vin??
Si deja on corrige...
~RaGE();
|
|
|
|