Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old July 4th, 2008, 03:35 AM
pauldepstein@att.net
Guest
 
Posts: n/a
Default 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
  #2  
Old July 4th, 2008, 03:45 AM
tony_in_da_uk@yahoo.co.uk
Guest
 
Posts: n/a
Default Re: Working through many typedefs

On Jul 4, 11:27 am, pauldepst...@att.net wrote:
Quote:
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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,338 network members.