473,738 Members | 7,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Avoiding "use of cast expressions in lvalues is deprecated"

Hi guys,

We have the following macro:

#define NEXT(type,p) (*((type*)(p))+ +)

It provides a way to poke variable sized data into an array of pcode
for a simple VM.
e.g,

NEXT(byte,pcode ) = PUSH;
NEXT(int,pcode) = constant;

But this technique now seems to be deprecated. It seems fairly safe to
me (pointers can always be interconverted) and I can't see any obvious
and efficient way to get around the error (particularly in the pcode
interpreter itself)

thanks in advance,
Steve Donovan.

Sep 19 '06
23 3964
On Tue, 19 Sep 2006 21:51:56 +0200, in comp.lang.c , Skarmander
<in*****@dontma ilme.comwrote:
>Oh, it's not just extensions. Aren't you just appalled that you can't
compile some K&R C code with the latest versions of gcc? As if rewriting a
fully functioning program to conform to ANSI improves it! How much would it
have cost to keep full K&R support in the compiler, anyhow?
I guess the standards committee would argue that its the price one
pays for improving the typechecking system. Presumably there are those
in world would have their cake and eat it, that would insist they want
safer code but don't want to pay the cost . The same people probably
insist its their right to drive rusty pollution emitting physically
unsound trucks, after all it was good enough for grandaddy up in the
hills fifty years ago.
>The regrettable result of changing the language is that developers are kept
busy for no immediate reward.
Speak for yourself! Good money in upgrading s/w to match modern
standards.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Sep 19 '06 #11
Mark McIntyre wrote:
On Tue, 19 Sep 2006 21:51:56 +0200, in comp.lang.c , Skarmander
<in*****@dontma ilme.comwrote:
>Oh, it's not just extensions. Aren't you just appalled that you can't
compile some K&R C code with the latest versions of gcc? As if rewriting a
fully functioning program to conform to ANSI improves it! How much would it
have cost to keep full K&R support in the compiler, anyhow?

I guess the standards committee would argue that its the price one
pays for improving the typechecking system.
But perfect programs don't need an improved typechecking system. It already
works, so we should leave it alone. Of course, I do expect my compiler
vendor to keep improving the compiler, just not the language it compiles.
Those ANSI C folks just missed the boat when K&R laid down the law.
>The regrettable result of changing the language is that developers are kept
busy for no immediate reward.

Speak for yourself! Good money in upgrading s/w to match modern
standards.
Yes, quite true. The "reward" I spoke of was in relation to the code
rewritten in the process (under the assumption that it's perfect, of
course), not the developers doing the rewriting... I should have been less
ambiguous.

S.
Sep 19 '06 #12
jacob navia posted:
I wanted to introduce the same extension as gcc what lvalued
casts is concerned several years ago, but a huge OUTCRY in
the lcc group refrained me from doing that...

What's wrong with the following?

#define L_VALUE_CAST(ty pe,expr) (*(type*)&(expr ))

Of course, it won't work with more complicated types such as arrays and
function pointers, but it's a start.

--

Frederick Gotham
Sep 19 '06 #13
jacob navia wrote:
Skarmander wrote:
>Oh, it's not just extensions. Aren't you just appalled that you can't
compile some K&R C code with the latest versions of gcc? As if
rewriting a fully functioning program to conform to ANSI improves it!
How much would it have cost to keep full K&R support in the compiler,
anyhow?
Wow, this is good news, I did not know that!!!
Don't get your hopes up. If people flock to a new compiler, it's not going
to be for K&R support.
I am finishing the lcc-lin32 version of lcc-win32 for linux.
It features a 32 bit compiler, much faster than gcc (approx
a speedup of 10 times).
Good for you. It may have niche uses.

Well, don't get me wrong, compilation speed is one important aspect of a
compiler, but I won't be recompiling my Ubuntu distribution with it any time
soon. Maybe in a year or so, when other people have gathered experiences.

Actually, make that two years.
This means I will get all those "clients" dissatisfied with
gcc.
Really? You mean to say your compiler has none of the issues specified here
http://gcc.gnu.org/onlinedocs/gcc-4....ibilities.html
*and* is compatible with gcc in other respects?

I take it you're also going to make your compiler free for commercial or
educational use? Oh, and where can I download the source, in case I find a
bug I need to fix yesterday?

Hmm, well, you're not going to get *all* clients dissatisfied with gcc. And
don't forget there are other contenders for the "faster than gcc" title,
even on Linux.
I wanted to introduce the same extension as gcc what lvalued
casts is concerned several years ago, but a huge OUTCRY in
the lcc group refrained me from doing that...

Maybe I should try again :-)
That would be evil[*]. There are perfectly portable ways of writing what you
can do with lvalued casts (leaving aside that some of it may nevertheless be
implementation-defined). For God's sake, it's not even hard to do! If you
deliberately implement this as an extension now, when even gcc is moving
away from it (with plenty of advance warning, I might add), you encourage
people to make (continued or new) use of a pointless extension. The result
is vendor lock-in, which is good for you, and proliferation of gratuitously
unportable code written in not-quite-C, which is good for people who don't
care about quality code. Neither of this is good for the world as a whole.

S.[*]I use the word in a strictly utilitarian sense.
Sep 19 '06 #14
st************* @gmail.com wrote:
Richard Tobin wrote:
It's never been standard C. It was allowed by some early C compilers
and in some drafts of the first ANSI C standard, and is allowed by gcc
as an extension.

Now that I never knew - sometimes it's unwise to learn a language from
a compiler.
No, it's _always_ unwise to learn a language from a compiler. The C
standard allows greate freedom in implementation, but also requires
them to make (and document) choices. As a consequence, the
implementation you 'learn' on one machine need not be the same as
others.
#define NEXT(type, p, t) ((t) = (p), p += sizeof(type), (type *)*(t))
#define NEXT(type, p) \
( * (type *) ( (p += sizeof(type)) - sizeof(type) ) )

Both assume that p is a pointer to a character type (amongst other
things.)
Thanks guys, that's exactly what I needed - the standard way to think
about the problem, and the pitfalls of doing it the cowboy method.
Well, it still has problems that the conversion of p to a type *
pointer need
not be defined (e.g. alignment). There are plenty of implementations
where
this method will fail miserably.

--
Peter

Sep 19 '06 #15
Mark McIntyre wrote:
On Tue, 19 Sep 2006 12:39:14 +0200, in comp.lang.c , jacob navia
<ja***@jacob.re mcomp.frwrote:

>>In my opinion, a compiler that introduces an extension should be
fair to the users that use that extension and never take it back
without a means to the users to keep their code as is.


Where possible, given new requirements placed upon the compiler by
standardisation .
>>It is apparently not the way gcc works, maybe as a result of the
C++ habit of invalidating code bases. In C++ is a daily problem that
code that works with version x.x of the compiler will stop working
in version x.x+1.


This from the man crying out for gets() to be removed from the C
standard. Double standards as well as inflammatory disinformation.
The proposal I published in comp.std.c was to make an
Appendix to the standard where obsolescent features would be
described, that are no longer part of the official standard.

Nowhere I wanted to just delete gets(). Users that want to use it
could use it using a compatibillity library based on that Appendix.
Whether an implementation follows that (non-normative) standard
Appendix is up to the implementation. Since all implementations have
gets() NOW, building such a compatibility library would be
very easy and most vendors would have it.

You are just misrepresenting my proposal, and then... YOU accuse
me of "double standards"!!!
Sep 20 '06 #16
jacob navia wrote:
Mark McIntyre wrote:
On Tue, 19 Sep 2006 12:39:14 +0200, in comp.lang.c , jacob navia
<ja***@jacob.re mcomp.frwrote:

>In my opinion, a compiler that introduces an extension should be
fair to the users that use that extension and never take it back
without a means to the users to keep their code as is.

Where possible, given new requirements placed upon the compiler by
standardisation .
>It is apparently not the way gcc works, maybe as a result of the
C++ habit of invalidating code bases. In C++ is a daily problem that
code that works with version x.x of the compiler will stop working
in version x.x+1.

This from the man crying out for gets() to be removed from the C
standard. Double standards as well as inflammatory disinformation.

The proposal I published in comp.std.c was to make an
Appendix to the standard where obsolescent features would be
described, that are no longer part of the official standard.

Nowhere I wanted to just delete gets(). Users that want to use it
could use it using a compatibillity library based on that Appendix.
Whether an implementation follows that (non-normative) standard
Appendix is up to the implementation. Since all implementations have
gets() NOW, building such a compatibility library would be
very easy and most vendors would have it.

You are just misrepresenting my proposal, and then... YOU accuse
me of "double standards"!!!
If gets() is removed from the normative text of the standard, a
conforming implementation cannot declare it in <stdio.h>, and must
accept any user definitions of gets.

Sep 20 '06 #17
Harald van Dijk wrote:
If gets() is removed from the normative text of the standard, a
conforming implementation cannot declare it in <stdio.h>, and must
accept any user definitions of gets.
Yes, of course. Why should it be kept in stdio?
It should be in "obsolete.h ", the header describing
"obsolete.l ib" or "obsolete.a ". To use gets, people
would just add
#include "obsolete.h "
and link with the appropiate library.

This is not just *forcing* people to avoid gets(), but
avoiding any official support for it, what is a different
approach.

Sep 20 '06 #18
jacob navia <ja***@jacob.re mcomp.frwrites:
Harald van Dijk wrote:
>If gets() is removed from the normative text of the standard, a
conforming implementation cannot declare it in <stdio.h>, and must
accept any user definitions of gets.

Yes, of course. Why should it be kept in stdio?
It should be in "obsolete.h ", the header describing
"obsolete.l ib" or "obsolete.a ". To use gets, people
would just add
#include "obsolete.h "
and link with the appropiate library.

This is not just *forcing* people to avoid gets(), but
avoiding any official support for it, what is a different
approach.
So you want to break existing code (by requiring it to add a #include
directive for a new header) *and* keep gets(). Sounds like the worst
of both worlds to me.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Sep 20 '06 #19
Keith Thompson wrote:
jacob navia <ja***@jacob.re mcomp.frwrites:
>>Harald van Dijk wrote:
>>>If gets() is removed from the normative text of the standard, a
conforming implementation cannot declare it in <stdio.h>, and must
accept any user definitions of gets.

Yes, of course. Why should it be kept in stdio?
It should be in "obsolete.h ", the header describing
"obsolete.lib " or "obsolete.a ". To use gets, people
would just add
#include "obsolete.h "
and link with the appropiate library.

This is not just *forcing* people to avoid gets(), but
avoiding any official support for it, what is a different
approach.


So you want to break existing code (by requiring it to add a #include
directive for a new header) *and* keep gets(). Sounds like the worst
of both worlds to me.
Yea of course I am always wrong.

The idea that wth some flag like
-std=c99compatib le

that include file is automatically included doesn't come to your
mind at all as in

#ifdef __STDC99_COMPAT IBLE__
#include "compatible .h"
#endif

in stdio.h

and the compiler would set __STDC99_COMPAT IBLE__
if that flag was passed at compile time
Sep 20 '06 #20

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

Similar topics

40
3038
by: Steve Juranich | last post by:
I know that this topic has the potential for blowing up in my face, but I can't help asking. I've been using Python since 1.5.1, so I'm not what you'd call a "n00b". I dutifully evangelize on the goodness of Python whenever I talk with fellow developers, but I always hit a snag when it comes to discussing the finer points of the execution model (specifically, exceptions). Without fail, when I start talking with some of the "old-timers"...
4
10721
by: John Devereux | last post by:
Hi, I would like some advice on whether I should be using plain "chars" for strings. I have instead been using "unsigned char" in my code (for embedded systems). In general the strings contain ASCII characters in the 0-127 range, although I had thought that I might want to use the 128-255 range for special symbols or foreign character codes. This all worked OK for a long time, but a recent update to the compiler on my system has...
7
16819
by: Olaf Baeyens | last post by:
I am testing VC++ 2005 and I get this warning: "warning C4996: 'strncpy' was declared deprecated" Does that mean that they might be phased out in VC++ 2006 or higher? Or does an alternative function exist as replacement?
42
2131
by: usenet | last post by:
I'm still confused about this and I can't find anywhere that explains it properly. I have the MS book "Access 2003" in front of me and I'm reading Part 5 about VB and so on. It's telling me about how to refer to a specific database and has the example:- Dim dbMyDb As DAO.Database Set dbMyDb = DBEngine.Workspaces(0).Databases(0)
2
1070
by: cruster | last post by:
Is it possible to indicate, that some method of a custom control is deprecated?
17
2510
by: arindam.mukerjee | last post by:
I was running code like: #include <stdio.h> int main() { printf("%f\n", 9/5); return 0; }
6
2909
by: Lighter | last post by:
How to read "The lvalue-to-rvalue, array-to-pointer, and function-to- pointer standard conversionsare not applied to the left expressions"? In 5.18 Comma operator of the C++ standard, there is a rule: "The lvalue-to-rvalue, array-to-pointer, and function-to-pointer standard conversionsare not applied to the left expressions" I could not understand what the rule means. I also searched the web and the groups and got nothing.
2
2889
by: r_ahimsa_m | last post by:
Hello, I am learning PHP5. I need to parse XML file and I found a solution in some book on PHP5 ("PHP5 Programming" by Rasmus Lerdors and others). Unfortunately I have two problems that I don't understand: Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of xml_set_object(). If you would like to enable call-time pass-by-reference, you can set...
30
3837
by: Medvedev | last post by:
i see serveral source codes , and i found they almost only use "new" and "delete" keywords to make they object. Why should i do that , and as i know the object is going to be destroy by itself at the end of the app for example: class test { public: int x;
0
8788
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,...
0
9476
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9263
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
9208
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...
1
6751
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4570
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...
1
3279
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
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.