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 6659261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:00:45+00:00 2026-05-26T02:00:45+00:00

I have encountered the #define pre-processor directive before while learning C, and then also

  • 0

I have encountered the #define pre-processor directive before while learning C, and then also encountered it in some code I read. But apart from using it to definite substitutions for constants and to define macros, I’ve not really understook the special case where it is used without a “body” or token-string.

Take for example this line:

#define OCSTR(X)

Just like that! What could be the use of this or better, when is this use of #define necessary?

  • 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-05-26T02:00:45+00:00Added an answer on May 26, 2026 at 2:00 am

    This is used in two cases. The first and most frequent involves
    conditional compilation:

    #ifndef XYZ
    #define XYZ
    //  ...
    #endif
    

    You’ve surely used this yourself for include guards, but it can also be
    used for things like system dependencies:

    #ifdef WIN32
    //  Windows specific code here...
    #endif
    

    (In this case, WIN32 is more likely defined on the command line, but it
    could also be defined in a "config.hpp" file.) This would normally
    only involve object-like macros (without an argument list or
    parentheses).

    The second would be a result of conditional compilation. Something
    like:

    #ifdef DEBUG
    #define TEST(X) text(X)
    #else
    #define TEST(X)
    #endif
    

    That allows writing things like:

    TEST(X);
    

    which will call the function if DEBUG is defined, and do nothing if it
    isn’t.

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

Sidebar

Related Questions

I have encountered a weird situation while updating/upgrading some legacy code. I have a
I'm trying to port a C# thread pool into C++ but have encountered some
I have occasionally encountered a pattern in code which resembles a monad but does
I have encountered a strange behavior while executing an sql query on the Oracle
I have an app that is nearly finished but encountered an annoying problem. In
I have encountered a difficulty in understanding the subroutine syntax. using the following code:
I have encountered a working (with XLC8 and MSFT9 compilers) piece of code, containing
Suppose I have #define foo in various header files. It may expand to some
Please forgive my attempts at necromancy, but I actually need to write some code
I am currently writing my first iPhone app, but have encountered an issue. I

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.