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

Custom compiler warning message

Hi,

I'm currently building a DoublePoint class as an extention on the
standard Point and PointF classes. The DoublePoint class will be part
of a bigger library and may be used by serveral people. It's posible to
convert from Point to DoublePoint. But when this is done implicit I
would like to give the user a compiler warning to keep them alert. Does
anyone know if this is possible and how it can be done?

Thanks!

Sorskoot

May 2 '06 #1
5 2349
I'm not sure if you could add your own warnings...

Do you lose percision going from Point to DoublePoint? If not, I don't
see why you'd even need a waring. If you would lose percision, I'd
think you'd only want to allow explicit casting.

Andy

May 2 '06 #2
There will be loss of precision. Well, in case of Point to DoublePoint
there won't but from DoublePoint to Point there will. I think i'll go
with explicit casting, for now...

Thanks...

May 2 '06 #3
For Point to DoublePoint, I wouldn't worry about warnings.. after all,
if there's no downside to the cast, it shouldn't matter..

Going the other way you indicate there will be.. so go with an explict
cast only. This is how floats, doubles and ints work, so you'll be
consistent with the framework itself.

Andy

May 2 '06 #4
Sorskoot <so******@gmail.com> wrote:
I'm currently building a DoublePoint class as an extention on the
standard Point and PointF classes. The DoublePoint class will be part
of a bigger library and may be used by serveral people. It's posible to
convert from Point to DoublePoint. But when this is done implicit I
would like to give the user a compiler warning to keep them alert. Does
anyone know if this is possible and how it can be done?


If you want to keep people alert, why not make it an explicit cast
instead? That way users can effectively tell the compiler that they
know what they're doing, without ending up having warnings. (I don't
know about you, but I never like having *any* warnings in my code.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
May 2 '06 #5
I agree, I'll go with the explicit cast.
Thanks for the replies!

Sorskoot

May 3 '06 #6

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

Similar topics

29
by: junky_fellow | last post by:
Consider the following piece of code: struct junk { int i_val; int i_val1; char c_val; }; int main(void) {
0
by: steven shingler | last post by:
Hi all - would like to write a custom attribute, which, when applied to a constructor will make the compiler issue a warning. Just like the Obsolete Attribute, but with a name of my choosing. Call...
2
by: Glen | last post by:
I'm working on a custom assembly and I'm trying to figure out the best approach to handling known constraints within the assembly, once compiled, to alert the developer at compile time of a...
15
by: bill salkin | last post by:
I'd like to create a custom error handler like this in VB.NET: .... try ... Throw ("Lender Name not in table") .... catch ("Lender Name not in table")
34
by: Bob | last post by:
Hi, The compiler gives Warning 96 Variable 'cmdSource' is used before it has been assigned a value. A null reference exception could result at runtime. Dim cmdSource as SQlClient.SQLDataReader...
2
by: prabhupr | last post by:
Hi Folks I was reading this article (http://www.dotnetbips.com/articles/displayarticle.aspx?id=32) on "Custom Attribute", written by Bipin. The only thing I did not understand in this article...
6
by: chrisb | last post by:
Hi, Does anyone know if it's possible to generate a custom compiler warning in vs2005? Something like the //todo: comments (possibly //warning: ), but it would show up in the warnings on every...
6
by: tropos | last post by:
For my sins, I'm maintaining some old C code which is migrated to C++. Dozens of lines of it looks like this: char *cfd_THE_ts_result_sql= "select TRADE_DATE , VALUE , " " from (" " select...
1
by: olduncleamos | last post by:
Hi all, Just wondering if it is possible for a custom control to emit compiler warning or even error? It would be great to flag the user at compile time if they made some inconsistent property...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
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...
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...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.