Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8575787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:46:25+00:00 2026-06-11T19:46:25+00:00

If a compiler has a certain type (ex. ptrdiff_t) as an embedded type, I

  • 0

If a compiler has a certain type (ex. ptrdiff_t) as an embedded type, I don’t want to typedef it again. I know that below code does not work properly that I expected.

#ifndef ptrdiff_t 
    typedef long int ptrdiff_t;
#endif

How can I check a certain type is already defined in the C compiler?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:46:26+00:00Added an answer on June 11, 2026 at 7:46 pm

    In your question you are a bit confusing 2 different things:

    There are built in types, like int, float, etc. These are standard types and they are defined is all compilers. Types like __int64 were introduced and standardized later. This means that they are defined in all recent compilers but only in some of the older compilers. You do not need to do anything to use them. At the same time you cannot figure out in your code if they are defined or not. This can be figured out only from the docs on the compiler. You can write:

    #ifdef MSVC
           .... Microsoft specific code
    #else
           .... Code for other compiler.
    #endif
    

    This approach allows you to create sort of compiler independent environment.

    Besides the built in types, there are types that come from the headers. Some headers have constructs like:

    #ifndef ptrdiff_t_DEFINED
        #define ptrdiff_t_DEFINED
        typedef long int ptrdiff_t;
    #endif
    

    Note that the macro-processor definitions stay apart from the definition of the type. You cannot check if the type is defined or not, but you can easily check if a macro definition is defined.

    What headers are included in your code you deside yourself. This means that these definitions are not in the compiler itself. They are in the set of definitions of the current translation unit. For compiler they have little difference from other type definitions that you write in your own code.

    Some compiler or system headers for not have “guarding defns” like in the example above. In this case the only thing that you can do is to track from what headers thay are coming and include/not include these headers, maby using your own #ifdef guards around the #include statements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My compiler (VC++ 6.0 sp6) has apparently gone insane. In certain pieces of code
Is there any compiler that has a directive or a parameter to cast integer
I've just downloaded from SVN the DUnit2 code base. Does someone has compiled it
Anyone want to share an Xcode project that has MGTwitterEngine in it? Mine won't
My group has a source analysis tool that enforces certain styles that we have
i have a class that has this function: typedef boost::shared_ptr<PrimShapeBase> sp_PrimShapeBase; class Control{ public:
I know that I can use templates to assume that certain classes used by
In C++, since you can have class-instances as members in structs, the compiler has
Java has compiler checked exceptions . When I made transition to C++, I learned
I have compiled this using Visual Studio 2010 compiler and it has compiler error

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.