Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 05:17 PM
F. Edward Boas
Guest
 
Posts: n/a
Default typedef and #ifdef

How can you check to see if a type is built-in or typedef'ed? For
example, an 8-bit integer could be u_int8_t, uint8_t, or unsigned
__int8, depending on the OS/compiler. I'd like to write code like:

#if defined(u_int8_t)
typedef u_int8_t BYTE;
#elif defined (uint8_t)
typedef uint8_t BYTE;
#elif defined (__int8)
typedef unsigned __int8 BYTE
#endif

However, this does not work, because built-in and typedef'ed types are
not "defined" according to #ifdef. So two questions: Is there a
work-around? And why doesn't C++ allow the above code?
  #2  
Old July 19th, 2005, 05:17 PM
Alf P. Steinbach
Guest
 
Posts: n/a
Default Re: typedef and #ifdef

On 11 Aug 2003 10:26:51 -0700, boas@stanford.edu (F. Edward Boas) wrote:
[color=blue]
>How can you check to see if a type is built-in or typedef'ed?[/color]

You can check whether a type is built-in by checking for all
built-in types (this list is not necessarily limited to the
C types); use template classes for this.

You cannot check whether a C++ type is a typedef, because a
C++ typedef just introduces an alternate _name_ for a type.

A typedef behaves differently in the language D.


 

Bookmarks

Thread Tools

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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 network members.
Post your question now . . .
It's fast and it's free

Popular Articles