473,699 Members | 2,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Working through many typedefs

While reading some source code, I saw a variable called "end" of type
"time". So I investigated what the type "time" meant and saw that
time was a typedef for "Real". So what does "Real" mean? "Real" is a
typedef for QL_REAL. So what does "QL_REAL" mean? QL_REAL is type
double via the line of code #define QL_REAL double.

I understand the need for generality and flexibility but this left me
thinking that "end" should have been declared as double in the first
place to make the code less opaque.

Is there any way to preserve the flexibility but avoid such an
unwieldy chain of typedefs. Is there any way of indicating to the
user via some sort of default type concept that type "time" is
generally double but could be changed later?

Since I admit that my first thought "Just make "time" a double in the
first place!" does lose flexibility, I'd like to ask how such a chain
of typedefs could (or whether it should) be avoided.

Thank you,

Paul Epstein
Jul 4 '08 #1
1 1373
On Jul 4, 11:27 am, pauldepst...@at t.net wrote:
While reading some source code, I saw a variable called "end" of type
"time". So I investigated what the type "time" meant and saw that
time was a typedef for "Real". So what does "Real" mean? "Real" is a
typedef for QL_REAL. So what does "QL_REAL" mean? QL_REAL is type
double via the line of code #define QL_REAL double.

I understand the need for generality and flexibility but this left me
thinking that "end" should have been declared as double in the first
place to make the code less opaque.

Is there any way to preserve the flexibility but avoid such an
unwieldy chain of typedefs. Is there any way of indicating to the
user via some sort of default type concept that type "time" is
generally double but could be changed later?

Since I admit that my first thought "Just make "time" a double in the
first place!" does lose flexibility, I'd like to ask how such a chain
of typedefs could (or whether it should) be avoided.
While obviously the ability to do this can be abused, there are many
cases when it's appropriate. Often it's the case that some library or
service presented in a header wants to use and expose a more
fundamental (often operating system specific) type, but they want to
preserve the ability to switch their clients across to some internal
or different underlying type (requiring a recompile but not client
code modification) if that ever becomes necessary.

Another possible approach is through any of the many varieties of
variant types, but they introduce often significant storage and
performance overheads, and oft-time potential for what are currently
compile-time errors to become much more serious run-time errors.

If it's bothering you, perhaps use an editor/IDE or writing a tool
that conveniently exposes/follows the chain of typedefs/defines.

Cheers,

Tony
Jul 4 '08 #2

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

Similar topics

2
1426
by: cppaddict | last post by:
Hi, I currently have a class in which I use all of the following a number of times (nb: Point is custom class): std::vector<Point> std::vector<Point>& const std::vector<Point> const std::vector<Point>&
2
1836
by: Levent | last post by:
Please consider the following Parent and Child template classes: template <class T> class Parent { public: typedef T type; typedef T& ref; /* pack of typedefs */ };
0
1763
by: Steven T. Hatton | last post by:
I copied what I believe is a complete representation of <iosfwd> from ISO/IEC 14882:2003(E). My understanding of the rules covering typedefs, templates and forward declarations is not very solid. As I understand what is presented here, the typedefs are declaring typedef-names which refer to incomplete types. That is to say, they are becoming synonyms for forward declarations of class template instances. I see nothing in the Standard...
6
1948
by: Erica | last post by:
Hi, I am currently working on a Pascal-to-C translation, and I am getting an error that I can't seem to debug. I have a globals.h file, and here is a snippet from it: -- typedef char ShortString;
30
6081
by: junky_fellow | last post by:
I was looking at the source code of linux or open BSD. What I found that lots of typedefs were used. For example, consider the offset in a file. It was declared as off_t offset; and off_t is typedefed as typedef long off_t; I wanted to know what advantage do we get by typedefs ? Why we did not declare
7
5993
by: Noah Roberts | last post by:
I have something like the following: template<ENUM X, int I = 0> class Generic { .... }; typedef Generic<Val1> v1_type; typedef Generic<Val2> v2_type;
132
4606
by: Frederick Gotham | last post by:
If we look at a programming language such as C++: When an updated Standard comes out, everyone adopts it and abandons the previous one. It seems though that things aren't so clear-cut in the C community. It would seem that C99 is the most up-to-date Standard, but far more people seem to be working off the C89 Standard. Could someone please explain to me why this is so? --
31
2701
by: Markus Pitha | last post by:
Hello, I'm using a template to simulate a LinkedList from Java.It works without problems, but when I want to use strings in main.cpp instead of char*, I get the following error message: $ ./Main terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct NULL not valid
18
1432
by: Philluminati | last post by:
I am writing a poker game which needs to work with cash. I am aware that there are problems with floats that make them unsuitable for storing money values. On top of this I may be expected to do operations such as £10.52 / 3. Which data type should I use instead? Is there an Industry standard one? Further to this, is anyone away of legally what the obligations would be when the outcome is 3.566666667? does the customer get 56 or 57p?...
0
8685
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, 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...
0
9032
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 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...
0
7743
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...
1
6532
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
4373
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
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3053
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
2342
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
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.