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

  • Home
  • SEARCH
  • 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 8458903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:12:15+00:00 2026-06-10T13:12:15+00:00

In porting a large piece of C++ code from Visual Studio (2008) to Xcode

  • 0

In porting a large piece of C++ code from Visual Studio (2008) to Xcode (4.4+), I encounter lines such as:

UNUSED_ALWAYS(someVar);

the UNUSED_ALWAYS(x) (through UNUSED(x)) macro expands to x which seems to silence Visual C++ just fine. It’s not enough for Clang however.

With Clang, I usually use the #pragma unused x directive.

The UNUSED_ALWAYS and UNUSED macros are defined in an artificial windows.h header which I control that contains a number of utilities to help Xcode compile Windows stuff.

Is there a way to define UNUSED(x) to expand to #pragma unused x? I tried this, which Clang fails to accept:

#define UNUSED(x) #pragma unused(x)

I also tried:

#define UNUSED(x) (void)(x)

Which seems to work. Did I miss anything?

  • 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-10T13:12:17+00:00Added an answer on June 10, 2026 at 1:12 pm

    Yup – you can use this approach for GCC and Clang:

    #define MON_Internal_UnusedStringify(macro_arg_string_literal) #macro_arg_string_literal
    
    #define MONUnusedParameter(macro_arg_parameter) _Pragma(MON_Internal_UnusedStringify(unused(macro_arg_parameter)))
    

    although mine did have the (void) approach defined for clang, it appears that Clang now supports the stringify and _Pragma approach above. _Pragma is C99.

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

Sidebar

Related Questions

I'm in the process of porting a large'ish (~1M LOC) project from a Window/Visual
I am working on porting a large number of .h and .lib files from
When I build with Xcode (I am porting a large project with tons of
I'm porting a UT3 game to UDK . It uses a large code library
Porting code from 32bit to 64bit. Lots of places with int len = strlen(pstr);
I'm porting some code from lisp, but I got stuck at this part (apparently
I'm porting some code from one framework library to another, which requires me to
I'm in the process of porting a large C++ application from Linux (gcc) to
I was about to begin porting a relatively large game from iPhone Obj-C to
I've recently been tasked with porting a large codebase of C++ code to XNA,

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.