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

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 1358
On Jul 4, 11:27 am, pauldepst...@att.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
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...
2
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
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. ...
6
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...
30
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...
7
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
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...
31
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: $...
18
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.