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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:07:54+00:00 2026-05-28T16:07:54+00:00

I am looking for a strange macro definition, on purpose: I need a macro

  • 0

I am looking for a strange macro definition, on purpose: I need a macro defined in such a way, that in the event the macro is effectively used in compiled code, the compiler will unfailingly produce an error.

The background: Since C11 had introduced several new keywords, and a new C++11 standard also added a few, I would like to introduce a header file in my projects (mostly using C89/C95 compilers with a few additions) to force developers to refrain from using these new keywords as identifier names, unless, of course, they are recognized as keywords in the intended fashion.

In the ancient past, I did this for new like this:

#define new *** /* C++ keyword, do not use */

And yes, it worked. Until it didn’t, when a programmer forgot the underscore in a parameter name:

void myfunction(uint16_t new parameter);

I used variants since, but I’ve never been challenged again.

Now I intend to create a file with all keywords not supported by various compilers, and I’m looking for a dependable solution, at best with a not too confusing error message. “Syntax error” would be OK, but “parameter missing” would be confusing already.
I’m thinking along the lines of

#define atomic +*=*+ /* C11 derived keyword; do not use */

and aside from my usual hesitation, I’m quite sure that any use (but not the definition) of the macro will produce an error.

EDIT: To make it even more difficult, MISRA will only allow the use of the basic source and execution character set, so @ or $ are not allowed.

But I’d like to ask the community: Do you have a better macro value? As effective, but shorter? Or even longer but more dependable in some strange situation? Or a completely different method to generate an error (only using the compiler, please, not external tools!) when a “discouraged” identifier is used for any purpose?

Disclaimer:
And, yes, I know I can use a grep or a parser to run on a nightly build, and report the warnings it finds. But dropping an immediate error on the developers desk is quicker, and certain to be fixed before checking in.

  • 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-28T16:07:55+00:00Added an answer on May 28, 2026 at 4:07 pm

    If the sport is for the shortest tokensequence that always produces an error, any combination of two 1 character operators that can’t legally occur together, but

    • don’t use ({ or }) because gcc has a special meaning for that
    • don’t use any sort of unbalanced parentheses because they can lead you far away until the error is recognized
    • don’t use < or > because they could match template parameters for C++
    • don’t use prefix operators as second character
    • don’t use postfix operators as first character

    This leave some possibilities

    • .., .| and other combinations with . since . expects a following identifier
    • &|, &/, &^, &,, &;
    • !|, !/, !^, !,, !;

    But actually to be more user friendly I’d also first place a _Pragma in it so the compiler would also spit a warning.

    #define atomic _Pragma("message \"some instructive text that you should read\"") ..
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a multithreaded Java application, I just tracked down a strange-looking bug, realizing that
I noticed that yesterday all the Fixed-width canvas apps started looking strange: the Facebook
Looking over some older code, I've run into a strange namespace error. Let's say
This is a strange request but I'm looking for buggy Python code. I want
I've found a strange looking piece of code in a project I have to
I have this strange problem. When debugging, I have sometimetimes code looking like this
I came across this strange looking declaration in some code early this morning (before
I'm looking over the Cloud Haskell package's Encoding.hs , and encountered some strange code
I noticed some strange looking statements when I viewed some c code in Disassembly.
Looking for feedback on : http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools

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.