472,961 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,961 software developers and data experts.

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

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?
Jul 19 '05 #1
1 10681
On 11 Aug 2003 10:26:51 -0700, bo**@stanford.edu (F. Edward Boas) wrote:
How can you check to see if a type is built-in or typedef'ed?

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.
Jul 19 '05 #2

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

Similar topics

by: Lorn | last post by:
I was hoping some of you might be able to help me understand the following code defining a typedef for a time query to the WINAPI. I understand the basics of what's going on, I just don't...
by: Generic Usenet Account | last post by:
This is a two-part question. (1) I have implemented a "Datastructure Registry" template class. I am getting no compiler warnings with older compilers, but newer compilers are generating the...
by: Martin Johansen | last post by:
Hello. I am programming a program which includes many libraries I have programmed. All libraries require this: typedef short word; But I get an error when I include this statement two...
by: stephen henry | last post by:
Hi all, I have a question that I'm having difficulty answering. If I have a struct: typedef struct my_struct_tag{ struct my_other_struct *other; } my_struct_tag
by: Merrill & Michele | last post by:
typedef struct { WORD versionNumber; WORD offset; } MENUITEMTEMPLATEHEADER; This is from vol 5 of unnamed platform's programmer's reference. I could make this conforming by enclosing...
by: Kenneth Brody | last post by:
Is there any way to know if there is a typedef of a given name? Specifically, I need to know if the compiler has a 64-bit integer type, and need to know if "int64_t" exists. Something like this...
by: jacob navia | last post by:
Hi Suppose you have somewhere #define BOOL int and somewhere else typedef BOOL int;
by: Thomas Carter | last post by:
Imagine that there is some include file f.h that contains the following line: typedef unsigned int ui32 ; My question is: If I have a C source file F.c that includes f.h, is it possible for...
by: informativeguy | last post by:
Hi, I did typedef int Man; After some code I get a necessity to use the same name Man for char. I mean to say,I need to typedef char Man; But how can I do this???
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.