I have nightmares about code similar to the following:
#define NUM_TRIES 10 // Number of tries before we eject them
....
if ( iCurrentTicks NUM_TRIES)
{
....
}
Maybe preprocessors and compilers have progressed where the previous is
no longer an issue. I remember distinctly that on the compilers I have
used in the past the previous if statement would become, after
pre-processing:
if( iCurrentTicks 10 // Number of tries before we eject them)
This would cause all kinds of issues when the code compiled.
Am I out of touch, or is this sort of thing still a potential issue? 7 6806 le*****@gmail.c om wrote:
I have nightmares about code similar to the following:
#define NUM_TRIES 10 // Number of tries before we eject them
...
if ( iCurrentTicks NUM_TRIES)
{
...
}
Maybe preprocessors and compilers have progressed where the previous is
no longer an issue. I remember distinctly that on the compilers I have
used in the past the previous if statement would become, after
pre-processing:
if( iCurrentTicks 10 // Number of tries before we eject them)
This would cause all kinds of issues when the code compiled.
Am I out of touch, or is this sort of thing still a potential issue?
I think you're definitely out of touch. Most headers I encountered
contained tons of such documented defines.
Stuart le*****@gmail.c om wrote:
I have nightmares about code similar to the following:
#define NUM_TRIES 10 // Number of tries before we eject them
...
if ( iCurrentTicks NUM_TRIES)
{
...
}
Maybe preprocessors and compilers have progressed where the previous
is no longer an issue. I remember distinctly that on the compilers I
have used in the past the previous if statement would become, after
pre-processing:
if( iCurrentTicks 10 // Number of tries before we eject them)
This would cause all kinds of issues when the code compiled.
Am I out of touch, or is this sort of thing still a potential issue?
Out of touch. Comments are replaced with a single space before any
macros are substituted.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Stuart Redmann wrote:
le*****@gmail.c om wrote:
>I have nightmares about code similar to the following:
#define NUM_TRIES 10 // Number of tries before we eject them
...
if ( iCurrentTicks NUM_TRIES) { ... }
Maybe preprocessors and compilers have progressed where the previous is no longer an issue. I remember distinctly that on the compilers I have used in the past the previous if statement would become, after pre-processing:
if( iCurrentTicks 10 // Number of tries before we eject them)
This would cause all kinds of issues when the code compiled.
Am I out of touch, or is this sort of thing still a potential issue?
I think you're definitely out of touch. Most headers I encountered
contained tons of such documented defines.
Stuart
isnt next better?
static const int NUM_TRIES 10; // Number of tries before we eject them
(type depends on the type of iCurrentTicks)
In article <eh**********@n ews.dtag.de>,
Stuart Redmann <De*******@web. dewrote:
>le*****@gmail. com wrote:
>I have nightmares about code similar to the following:
#define NUM_TRIES 10 // Number of tries before we eject them
...
if ( iCurrentTicks NUM_TRIES) { ... }
Maybe preprocessors and compilers have progressed where the previous is no longer an issue. I remember distinctly that on the compilers I have used in the past the previous if statement would become, after pre-processing:
if( iCurrentTicks 10 // Number of tries before we eject them)
This would cause all kinds of issues when the code compiled.
Am I out of touch, or is this sort of thing still a potential issue? I think you're definitely out of touch. Most headers I encountered contained tons of such documented defines.
Once upon a time, some C++ compilers were using C preprocessors
(preprocessors from C compilers, usually run stand alone)
which meant //'s were being processed out of sync if you will.
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port now in beta!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
VJ wrote:
le*****@gmail.c om wrote:
I have nightmares about code similar to the following:
#define NUM_TRIES 10 // Number of tries before we eject them
isnt next better?
static const int NUM_TRIES 10; // Number of tries before we eject them
Yes, of course, assuming you add the =
namespace { } instead of static may be even better.
HTH,
Michiel Salters Mi************* @tomtom.com wrote:
VJ wrote:
le*****@gmail.c om wrote:
I have nightmares about code similar to the following:
>
#define NUM_TRIES 10 // Number of tries before we eject them
isnt next better?
static const int NUM_TRIES 10; // Number of tries before we eject them
Yes, of course, assuming you add the =
namespace { } instead of static may be even better.
Actually, it's superfluous because const objects already have internal
linkage by default.
Note: This is different from C where const has extern linkage by
default.
Regards,
Bart.
Thank you to everyone that responded.
I will attempt to force a mental paradigm shift so when I see a
"//" type comment in C++, I won't freak out ;-)
Personally, I don't think I will ever code that way. As I said, I
have too many bad memories. le*****@gmail.c om wrote:
I have nightmares about code similar to the following:
#define NUM_TRIES 10 // Number of tries before we eject them
...
if ( iCurrentTicks NUM_TRIES)
{
...
}
Maybe preprocessors and compilers have progressed where the previous is
no longer an issue. I remember distinctly that on the compilers I have
used in the past the previous if statement would become, after
pre-processing:
if( iCurrentTicks 10 // Number of tries before we eject them)
This would cause all kinds of issues when the code compiled.
Am I out of touch, or is this sort of thing still a potential issue?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Uwe Ziegenhagen |
last post by:
Hello,
my fellows and me implement a c++ tool that is able to divide blank/tab
separated files into <number>, <text>, <c-singlelinecomment> and
<multilinecomment>. So far it's not working bad, we have just one
problem if I call the a.exe that gcc compiles with the following
textfile (./a.exe < test.txt) he does not match the multiline comments
correctly.
*test.txt contains:
|
by: Nobody |
last post by:
DB2 500G database, Wintel, heavily loaded OLTP (5M+ transactions a day;
all transactions are extremely small, all selects are controlled
(no ad-hoc), 99% of all selects are very small (no table
scans, index scans are very limited in size) ). Write performance
is generally more important than read performance, read performance
of heavy queries (the ones with table scans) is not important at all.
Question: how to spread data across...
|
by: djinni |
last post by:
It's been a while since I've written anything in C, and
I was hoping to get some feedback on the following code.
As far as I can tell, the program works fine, but I'm not
sure I'm cleaning all the memory up properly, and I think
the "tokenize_my_string" function can probably be made better.
This program prompts the user for a text sentence,
then re-orders the words in a random fashion...
...
|
by: Alex Vinokur |
last post by:
Is there any tool to count C-program lines except comments?
Thanks,
=====================================
Alex Vinokur
mailto:alexvn@connect.to
http://mathforum.org/library/view/10978.html
news://news.gmane.org/gmane.comp.lang.c++.perfometer
=====================================
|
by: Adam Barr |
last post by:
For a book I am working on, I have written a brief (7 page) summary
of C. The intent of this is that an experienced programmer who did
not know C would be able to get enough information to read and
understand C programs. It is not meant to be a 100% complete
summary of the language, but everything in there should be correct.
If anyone is interested, please feel free to read it and send me
comments. Note that the material is copyrighted,...
| |
by: William L. Bahn |
last post by:
I'm looking for a few kinds of feedback here.
First, there is a program at the end of this post that has a
function kgets() that I would like any feedback on - including
style.
Second, for those that are interested, I present an outline of
the approach I am looking at using in class this semester. I
would be very interesting in any feedback on that, but if you are
not interested, feel free to skip over it.
|
by: tjb |
last post by:
I often see code like this:
/// <summary>
/// Removes a node.
/// </summary>
/// <param name="node">The node to remove.</param>
public void RemoveNode(Node node) {
<...>
}
|
by: jacob navia |
last post by:
Recently, a heated debate started because of poor mr heathfield
was unable to compile a program with // comments.
Here is a utility for him, so that he can (at last) compile my
programs :-)
More seriously, this code takes 560 bytes. Amazing isn't it? C is very
ompact, you can do great things in a few bytes.
Obviously I have avoided here, in consideration for his pedantic
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |