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

remotely legal?

#define new DEBUG_NEW
I can't imagine that has defined behavior.

Jan 18 '07 #1
5 1764
"Noah Roberts" <ro**********@gmail.comwrote in
news:11**********************@11g2000cwr.googlegro ups.com:
#define new DEBUG_NEW
I can't imagine that has defined behavior.


Why not? That's just a preprocessor directive that wherever it sees "new",
replace with "DEBUG_NEW". Whether that has a good or bad effect on the
rest of your code depends on the rest of your code. But that line in
isolation has perfectly defined behaviour.
Jan 18 '07 #2
Andre Kostur wrote:
"Noah Roberts" <ro**********@gmail.comwrote in
news:11**********************@11g2000cwr.googlegro ups.com:
>#define new DEBUG_NEW
I can't imagine that has defined behavior.



Why not? That's just a preprocessor directive that wherever it sees
"new",
replace with "DEBUG_NEW". Whether that has a good or bad effect on the
rest of your code depends on the rest of your code. But that line in
isolation has perfectly defined behaviour.
As soon as you find that line not in isolation but within a translation unit
(i.e., as soon as you try to actually compile that line), clause
[17.4.3.1.1/2] kicks in:

A translation unit that includes a header shall not contain any macros
that define names declared or defined in that header. Nor shall such a
translation unit define macros for names lexically identical to keywords.
Best

Kai-Uwe Bux
Jan 18 '07 #3

Kai-Uwe Bux wrote:
As soon as you find that line not in isolation but within a translation unit
(i.e., as soon as you try to actually compile that line), clause
[17.4.3.1.1/2] kicks in:

A translation unit that includes a header shall not contain any macros
that define names declared or defined in that header. Nor shall such a
translation unit define macros for names lexically identical to keywords.
Yeah, I didn't think it was legal.

Jan 18 '07 #4
Kai-Uwe Bux <jk********@gmx.netwrote in
news:eo**********@murdoch.acc.Virginia.EDU:
Andre Kostur wrote:
>"Noah Roberts" <ro**********@gmail.comwrote in
news:11**********************@11g2000cwr.googlegr oups.com:
>>#define new DEBUG_NEW
I can't imagine that has defined behavior.



Why not? That's just a preprocessor directive that wherever it sees
"new",
replace with "DEBUG_NEW". Whether that has a good or bad effect on
the rest of your code depends on the rest of your code. But that
line in isolation has perfectly defined behaviour.

As soon as you find that line not in isolation but within a
translation unit (i.e., as soon as you try to actually compile that
line), clause [17.4.3.1.1/2] kicks in:

A translation unit that includes a header shall not contain any
macros that define names declared or defined in that header. Nor
shall such a translation unit define macros for names lexically
identical to keywords.
Huh... didn't know that it was explicitly disallowed. I would have figured
it would have been under the heading of "really bad idea to do", like
"#define if while"......

Oh wait... That's under the section of "Library introduction". Aren't
those restrictions only on headers that are supplied by the C++ Standard
Library, and is not imposing additional requirements on user-supplied
headers? I interpret that to read that Standard Library headers will not
pull stunts like the aforementioned "#define if while" (or to word another
way, you can count on the standard library not messing with reserved
keywords).
Jan 18 '07 #5
Andre Kostur wrote:
Kai-Uwe Bux <jk********@gmx.netwrote in
news:eo**********@murdoch.acc.Virginia.EDU:
>Andre Kostur wrote:
>>"Noah Roberts" <ro**********@gmail.comwrote in
news:11**********************@11g2000cwr.googleg roups.com:

#define new DEBUG_NEW
I can't imagine that has defined behavior.


Why not? That's just a preprocessor directive that wherever it sees
"new",
replace with "DEBUG_NEW". Whether that has a good or bad effect on
the rest of your code depends on the rest of your code. But that
line in isolation has perfectly defined behaviour.

As soon as you find that line not in isolation but within a
translation unit (i.e., as soon as you try to actually compile that
line), clause [17.4.3.1.1/2] kicks in:

A translation unit that includes a header shall not contain any
macros that define names declared or defined in that header. Nor
shall such a translation unit define macros for names lexically
identical to keywords.

Huh... didn't know that it was explicitly disallowed. I would have
figured it would have been under the heading of "really bad idea to do",
like "#define if while"......

Oh wait... That's under the section of "Library introduction". Aren't
those restrictions only on headers that are supplied by the C++ Standard
Library, and is not imposing additional requirements on user-supplied
headers?
No, the restrictions mentioned in this section are all about what client
code may or may not do. The point of these provisions is to make sure that
the standard library can rely on the meanings of all keywords and reserved
identifiers. From the standard [17.4.3] "Constraints on programs":

This subclause describes restrictions on C++ programs that use the
facilities of the C + + Standard Library.

As you see: restrictions on programs that _use_ the library not restrictions
on the implementation of the library.

They only thing funny is that you seem to be allowed to redefine new
provided you do not include any standard headers whatsoever.
I interpret that to read that Standard Library headers will not
pull stunts like the aforementioned "#define if while" (or to word another
way, you can count on the standard library not messing with reserved
keywords).
It's the other way around.
Best

Kai-Uwe Bux
Jan 19 '07 #6

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

Similar topics

6
by: Hank | last post by:
Hi, I was wondering how I would execute a file remotely? For example, test.exe resides on machine A, my python script is running on Machine B. I would like to execute "test.exe -parameters" on...
2
by: faktujaa | last post by:
Hi, I have created an application that uses IIS to host remote components. All the remote components are listed in app.config in client and web.config in server. Now the app.config can contain...
1
by: John | last post by:
Hi We have our web site remotely hosted by a service provider. What we need is to from time to time remotely upload transactions to the site from our office vb.net database app, so the site can...
2
by: Evan Camilleri | last post by:
how can I create a web application remotely? i have access to a server and would like to create a web-application in a folder - if it is my IIS then i right click, properties and press create...
7
by: John | last post by:
Hi We have our web site remotely hosted by a service provider. We need to, from time to time, remotely upload transactions to the site from our office vb.net app. The question is how can I...
0
by: Terry Olsen | last post by:
Is there a way to remotely add/change/delete Local User/Group accounts remotely from VB.Net? We have a utility that would allow us to add a username to a local "netop" group on a PC. This then...
0
by: Marc Melancon | last post by:
I have a situation where accessing perfmon counters remotely does not display the same list of Performance Objects remotely as it does when doing it from the host of SQL Server. From the host of...
8
by: Sean DiZazzo | last post by:
Is there something special you have to do to get a wxPython app to run remotely under xwindows? My Tkinter apps always automatically work that way, so I was surprised to even be confronted with...
12
by: helveticus | last post by:
I'm in the process of finalizing my site. I spent quite a bit of time designing content pages and would like to cut on development time by simply managing the DB (SQL server, evt. MySQL) via MS...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
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,...
0
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...

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.