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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:32:11+00:00 2026-05-26T08:32:11+00:00

The following preprocessor macro: #define _VARIANT_BOOL /##/ is not actually valid C ; roughly

  • 0

The following preprocessor macro:

#define _VARIANT_BOOL /##/

is not actually valid C; roughly speaking, the reason is that the preprocessor is defined as working on a stream of tokens, whereas the above assumes that it works on a stream of characters.

On the other hand, unfortunately the above actually occurs in a Microsoft header file, so I have to handle it anyway. (I’m working on a preprocessor implementation.)

What other cases have people encountered in the wild, be it in legacy code however old as long as that code may be still in use, of preprocessor macros that are not actually valid, but work anyway because they were written under compilers that use a character oriented preprocessor implementation?

(Rationale: I’m trying to get some idea in advance how many special cases I’m going to have to hack, if I write a proper clean standard-conforming token oriented implementation.)

  • 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-26T08:32:11+00:00Added an answer on May 26, 2026 at 8:32 am

    The relevant part of the standard (§6.10.3.3 The ## operator) says:

    If the result is not a valid preprocessing token, the behavior is undefined.

    This means that your preprocessor can do anything it likes and still be standard conforming, including emulating the common behaviour.

    I think you can still have a “token-based” implementation and support this behaviour, by specifying that when the result of the ## operator is not a valid preprocessing token, the result is the two operand tokens unchanged. You may also want to have your preprocessor emit a warning about the invalid code.

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

Sidebar

Related Questions

I have a preprocessor macro defined in build settings FOO=BAR That value I want
I need help doing the following: a preprocessor macro label(x) shall output #x, e.g.,
I have the following preprocessor divective: #ifndef NDEBUG #define TRACE printf #else #define TRACE(...)
My problem is quite simple. I want the following macro #define PROXYPASS(name, param) \
If I use the macro: #define AND in the following way: if(...) { ...
Consider the following macro definitions and invocation: #define x x[0] #define y(arg) arg y(x)
I've got the following Macro to define a new function following a special naming
Without going into the gory details I want to use a #define macro that
If I write a #define that performs an operation using other preprocessor constants, is
Is there a way to do the following preprocessor directives in Python? #if DEBUG

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.