|
Nibu babu thomas wrote: Since it's not a normal pointer but a far one hence long
Its normal pointer(In fact there is no concept of normal pointer, pointer is pointer , thats all. It was there on 16 bit OS as 'near', 'far' and normal pointer). As Michael pointed out, difference was with win16 . And its there for backword compatibility.
Nibu babu thomas wrote: int was two bytes and long was four bytes.
int is 4 bytes as well, isn't it ?
|
|
|
|
|
prasad_som wrote: In fact there is no concept of normal pointer
What I meant with normal pointer is near pointer. When we declare a pointer
int *p
It's treated as near pointer we had to explicitly declare a far pointer using the far keyword. Hence I used the term normal.
prasad_som wrote: int is 4 bytes as well, isn't it ?
In Turbo C++ int is two bytes and long is 4 bytes. I started programmng in turbo hence said that. Maybe in Win16 int is 2 bytes and long 4 bytes, can't say since I haven't programmed in that environment but in Win32 both are of the same size.
|
|
|
|
|
'far' and 'near' are obsolete now.
Nibu babu thomas wrote: What I meant with normal pointer is near pointer. When we declare a pointer
int *p
It's treated as near pointer
In fact, its 'far' pointer of old days.
|
|
|
|
|
prasad_som wrote: 'far' and 'near' are obsolete now.
They are not obsolete but they are the same.
prasad_som wrote: In fact, its 'far' pointer of old days.
No. You are wrong. You had to explicitly declare a far pointer. You can also explicitly declare a near pointer using the near keyword but there was no need since that's the default. Besides far and near there are huge pointers too ( maybe base pointers too I remember using it in turbo ).
But there's no need for such pointer classifications now ( can't say about the future ) as Win32 does not distinguish between near and far addresses.
|
|
|
|
|
Nibu babu thomas wrote: They are not obsolete
Actually, they are obsolete. In fact, this whole concept is dead and burried.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
Nibu babu thomas wrote: No. You are wrong. You had to explicitly declare a far pointer. You can also explicitly declare a near pointer using the near keyword but there was no need since that's the default
Can you give me example of this ? I wonder how you are able to use kewords 'far', 'near' ?
|
|
|
|
|
prasad_som wrote: I wonder how you are able to use kewords 'far', 'near' ?
near int *pFarPtr = 0;<br />
far int *pFarPtr = 0;
You can try this in turbo. You can use the sizeof operator to see the difference. Maybe you will have to put an underscore before of after near and far.
You won't see the difference in Win32 but in Win16 or DOS you may.
In MS VC you won't get any error as these keywords are #defined to expand to empty strings.
I used to use far frequently for directly accessing vdu.
For eg:
char far *pcVDUStart = 0xB8000000;
|
|
|
|
|
Nibu babu thomas wrote: You can try this in turbo
Sorry Nibu, I dont have.
Nibu babu thomas wrote: You won't see the difference in Win32 but in Win16 or DOS you may.
Thats why I used word obsolete.
Nibu babu thomas wrote: In MS VC you won't get any error as these keywords are #defined to expand to empty strings.
Again, these are not keywords. they are just defines for backword compa. And it doesn't expand in to empy string. It is just define.
#define far // thats all
Nibu babu thomas wrote: I used to use far frequently for directly accessing vdu.
For eg:
char far *pcVDUStart = 0xB8000000;
It just expands to
char *pcVDUStart = 0xB8000000;
|
|
|
|
|
prasad_som wrote: Again, these are not keywords. they are just defines for backword compa. And it doesn't expand in to empy string. It is just define.
Empty string meant expands to nothing.
prasad_som wrote: char *pcVDUStart = 0xB8000000;
You are talking of Win32 but I am talking about programming in DOS. All the above statements were in relation to programming in DOS as I started of programming in DOS.
|
|
|
|
|
prasad_som wrote: No, empty string means "".
Yes but here expands to nothing .
|
|
|
|
|
prasad_som wrote: There is difference betn "expands to nothing" and "expands to "" ".
Yes there is but here I meant expands to nothing...
From MSDN...
Because the types NEAR and FAR are defined in WINDEF.H, they are
automatically handled by the include file, which redefines them as
<code>empty strings </code>for Win32. Thus, NEAR and FAR are ignored.
If you do not include WINDEF.H, a convenient solution is to use
the /D command-line option to replace the keywords by <code>empty
strings</code>. For example:
/D_near= /D_far= /D__near= /D__far=
|
|
|
|
|
Hi,
I have a project in which there are lots of places where a double is directly converted into an int without any explicit cast. Is there a way by which I can get warning in all the places where something like this happens.
The gcc compiler shows a warning something like "warning: converting to ‘int’ from ‘double’" but the with the same code vc++ compiler is not showing any warning.
Any idea how I can get these warnings?
Thanks a lot!!
|
|
|
|
|
You need to use warning level 4.
Use Project Setting-->C/C++-->General-->Warning level .
But it is not recommended to this level. As, warnings though this level can be safely ignored.
|
|
|
|
|
I tried setting the warning level to 4, but it is still not showing these kind of warnings.
|
|
|
|
|
Rebuild and see. There will be lots of warnings. You need to locate for this particular.
|
|
|
|
|
No, I am not getting any such warning.
Please help
Thanks a lot!!
|
|
|
|
|
Can you show code, you are expecting to generate this warning ? Which IDE you are using ?
|
|
|
|
|
The code is something like
<br />
class Value<br />
{<br />
public:<br />
Value(double v);<br />
double getValue() const;
private:<br />
double val;<br />
};<br />
<br />
int main()<br />
{<br />
Value v1(11.0);<br />
int a = v1.getValue();
}<br />
gcc generates warning for this but the vc++ compiler is not generating any warning. I am Visual Studio .net 2002.
Thanks a lot
|
|
|
|
|
This clearly generates warning with level 4 on VC6 and with level 3 on VS2K5 .
Mithin wrote: I am Visual Studio .net 2002
I dont have this IDE to test. But that should not be problem. I thing you are not setting warning level properly.
Test this code with VC6 .
|
|
|
|
|
prasad_som wrote: You need to use warning level 4.
...
But it is not recommended to this level. As, warnings though this level can be safely ignored.
Not? I always set my projects to warning level 4 and try my best to eliminate all warnings.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
PJ Arends wrote: Not? I always set my projects to warning level 4 and try my best to eliminate all warnings.
Same here. To suggest otherwise is bad advise.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
The version of STL that came with VC6 would overwhelm you with warnings, but later versions have fixed that. Even with VC6 a couple of pragmas in the stdafx.h header file would eliminate those errors. There is an article somewhere here on CP on how to do that.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
PJ Arends wrote: The version of STL that came with VC6 would overwhelm you with warnings, but later versions have fixed that.
True.
As mentioned earlier, this particular warning is level 3 though in VS2K5 .
|
|
|
|
|
prasad_som wrote: But it is not recommended to this level. As, warnings though this level can be safely ignored.
I don't think that an implicit conversion from double to int should be ever safely ignored.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Yes. I was refering to level 4 warnings. As you can see my further posts about this particular warning. Should be treated as level 3 warning and it is level 3 warning in VS2k5 .
|
|
|
|