473,809 Members | 2,951 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C style casts

Where is it in the standard that C style casts are labeled depricated?
I read that on a lot of websites but I can't find it in the standard.
I have BS ISO/IEC 14882:2003 (2nd ed) as published by John Wiley &
Sons. I'm in the middle of a standard argument on this issue and
safety isn't convincing my opponents - deprication might.

Jan 31 '06
24 1985
On 1 Feb 2006 19:18:11 -0800, mi************* @yahoo.com <mi************ *@yahoo.com> revealed:
John Carson wrote:
You are conceding ground you should not.


I haven't conceded anything. My initial stance is clear in my first
post. My second post is based on rereading the text and questioning the
nature of the comments.

Anyway, the idea is to avoid using C-style casts. Bottom line, if they
are removed from the language in future, then whoever takes that advice
will not be impacted.


I find it highly unlikely that a feature as widely used as c-style casts
will ever be removed in the future. I wouldn't avoid it just because of this.
It's true that c++ style casts usually show the programmer's intent more clearly
but imho it doesn't really matter; any half decent programmer will know how
both styles of typecasts work anyway and can read/use them equally well.
This really is not an issue worth fighting over.

--

Honesty never goes unpunished.

Feb 2 '06 #21
Pete Becker wrote:
Dakka wrote:

In this context, deprecation means 'frowned upon' not 'no longer
supported'.


In this context (i.e. standard C++) deprecated means that the C++
language definition says they are deprecated, which in turn means that
they might be removed from a future standard.

Yes and pedantry thrives in this group. We all know it is not in the
standard. I won't be telling anybody it is. But *I* consider them
deprecated as do many others (including Stroustrup - see earlier post).
And in *that* context - 'frowned upon' they are. Do you use them? If
not, why?

--dakka

*Dykstra's Observation:*
/If debugging is the process of removing bugs, then programming must be
the process of putting them in./
Feb 2 '06 #22
evil wrote:
It's true that c++ style casts usually show the programmer's intent more clearly
but imho it doesn't really matter; any half decent programmer will know how
both styles of typecasts work anyway and can read/use them equally well.
This really is not an issue worth fighting over.


I'd say it's importance was somewhere between const correctness and
exception specifications. I'd lean towards the former.

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Feb 2 '06 #23
Dakka wrote:
Pete Becker wrote:
Dakka wrote:

In this context, deprecation means 'frowned upon' not 'no longer
supported'.

In this context (i.e. standard C++) deprecated means that the C++
language definition says they are deprecated, which in turn means that
they might be removed from a future standard.

Yes and pedantry thrives in this group. We all know it is not in the
standard.


On the contrary: many people have expressed surprise that it is not.
I won't be telling anybody it is. But *I* consider them
deprecated as do many others (including Stroustrup - see earlier post).
No, he said they "should have been deprecated." That carefully preserves
the meaning of the technical term "deprecated ". Call it pedantry if you
like, but sloppy terminology is responsible for much of the confusion in
this discussion (and in newsgroup discussions in general).
And in *that* context - 'frowned upon' they are.
Sure: some people frown upon everything.
Do you use them? If
not, why?


Yes, I use them.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Feb 2 '06 #24

Dakka wrote:
Pete Becker wrote:
Dakka wrote:

In this context, deprecation means 'frowned upon' not 'no longer
supported'.
In this context (i.e. standard C++) deprecated means that the C++
language definition says they are deprecated, which in turn means that
they might be removed from a future standard.

Yes and pedantry thrives in this group. We all know it is not in the
standard. I won't be telling anybody it is. But *I* consider them
deprecated as do many others (including Stroustrup - see earlier post).


This isn't pedantry. The difference between depricated and, "should
be," is very important. If they are depricated then any C++ code that
uses them must be changed or you risk running into much trouble later.
If they, "should be," then there is no chance that they will suddenly
not work anymore when you upgrade or switch compilers.
And in *that* context - 'frowned upon' they are. Do you use them? If
not, why?


I don't use them because they are ugly as hell. C++ casts have a much
cleaner syntax and you don't see crap loads of parantheses around them.
They are also much safer and declare the writer's intention much
clearer. When you see a C-style cast on a const object that removes
const and changes type, which of those things were the developer's
intention or did he actually intend to do both? Finally, searches on
C++ casts are much easier.

In other words I don't use them for all the reasons everyone says they
are better. Nothing new there.

Feb 2 '06 #25

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

Similar topics

26
2559
by: Steven T. Hatton | last post by:
The code shown below is an example from the Coin3D documentation. I believe the use of the C-style cast is safe under the circumstances, but from what I've been exposed to (TC++PL(SE)), I would favor using a static_cast. Is there any technical reason to favor the C-style over a static_cast? http://doc.coin3d.org/Coin/index.html void foo(SoNode * node) { if (node->getTypeId() == SoFile::getClassTypeId()) {
15
1739
by: Christopher Benson-Manica | last post by:
If you had an unsigned int that needed to be cast to a const myClass*, would you use const myClass* a=reinterpret_cast<const myClass*>(my_val); or const myClass* a=(const myClass*)myVal; ?
3
1475
by: Howard | last post by:
Hi, I am maintaining a lot of code that is rife with C-style casts. I've seen a lot of comments that one should not use C-style casts at all. But I'm wondering what harm there could be in doing so with the built-in types. For example, if you have a long which needs to be passed to a function as an unsigned long, or a char* that needs to be passed as an unsigned char*, or an unsigned int that needs to be passed as a long, isn't it...
1
1395
by: Roy Smith | last post by:
I've got about 100 KLOC in which I want to find any uses of old C-style casts. Are there any good tools for this? Has anybody come up with a regex which does a decent job of finding them, or are there better ways to do it?
3
2311
by: Neil Zanella | last post by:
Hello, I would like to ask the following question concerning the C# as operator. I would like to know whether the difference between using a C-style cast such as double x = 0; float y = (double) x; and using the as operator is simply that as works on references rather
11
18274
by: esuvs81 | last post by:
Hi all. In short, is there any performance difference between: float f = 10.0f; int i = static_cast<int>(f); and float f = 10.0f; int i = int(f);
2
1385
by: Noah Roberts | last post by:
I have a class, that inherits from a class that inherits virtually from another class. I have a breakdown occuring and it is not wrt the virtually inherited class but one of the other MIed pure virtual classes. I get this in my call stack at the point of explosion: Flo.exe!DDocument::Dispatch(DFZone * ptr=0x0298d260) Line 94 + 0x32 bytes C++ Flo.exe!DDocument::Dispatch(DFZone * __A0=0x0298d260) + 0x2f
5
5931
by: brekehan | last post by:
I've always been a little sketchy on the differences between static, dynamic, and reinterpret casting. I am looking to clean up the following block by using C++ casting instead of the C style casting. from what I am reading, I should use reinterpret cast in this situation, is that correct? Why does static and dynamic casting fail me? // please excuse the windows types, it is necessary in this code, // but the question remains C++ related
0
9600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10375
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10114
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9198
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.