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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:47:34+00:00 2026-06-17T17:47:34+00:00

Using the -Wunused-parameter flag, you can enforce __unused for unused parameters, as a compiler

  • 0

Using the -Wunused-parameter flag, you can enforce __unused for unused parameters, as a compiler optimization. The following code causes two warnings:

#include <stdio.h>
int main(int argc, char **argv) {
  printf("hello world\n");
  return 0;
}

These warnings are fixed by adding __unused the unused arguments.

#include <stdio.h>
int main(int __unused argc, char __unused **argv) {
  printf("hello world\n");
  return 0;
}

When you use a parameter marked __unused, clang 4.1 does not warn or error.

#include <stdio.h>
int main(int __unused argc, char __unused **argv) {
  printf("hello world. there are %d args\n", argc);
  return 0;
}

The same behavior is exhibited using __attribute__((unused)).

int main(int __attribute__((unused)) argc, char __attribute__((unused)) **argv) {

Is there a way to warn or error on __unused? What would happen should you accidentally leave an __unused on a used parameter? In the above example argc appears to have the correct value, although it could be the compiler not taking advantage of the hint, and I wouldn’t rely on this behavior without more understanding.

  • 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-17T17:47:36+00:00Added an answer on June 17, 2026 at 5:47 pm

    The __unused attribute is intended to prevent complaints when arguments to functions/methods or functions/methods are unused, not to enforce their lack of use.

    The term used in the GCC manual is:

    This attribute, attached to a function, means that the function is meant to be possibly unused

    And for variables:

    This attribute, attached to a variable, means that the variable is meant to be possibly unused.

    The most common use is for development against an interface – e.g. callbacks, where you may be forced to accept several parameters but don’t make use of all of them.

    I use it a bit when I’m doing test driven development – my initial routine takes some parameters and does nothing, so all the parameters take __attribute__((unused)). As I develop it I make use of the parameters. At the end of development I remove them from the method, and see what shakes out.

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

Sidebar

Related Questions

I'm trying to find unused functions in my codebase by using GCC's -Wunused-function flag.
Using this code, the following execution yields strange results: C 100 R W The
Using the DateTime class, if I try to run the following code: $mydate =
Using Play 2.1-RC1 I can't write simple test. Here's the action code: def echoTestTagFromXml
Using MongoDB C# Driver (official form 10gen), I'm doing the following code: using (database.RequestStart())
I compiled the code below using Ideone.com and the following warning popped up. rtctimer.c:
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
Using Location.getBearing(); I seem to get randomly changing bearings. Aka, I can turn the
I'm trying to compile a little project that includes windows.h using the clang compiler.
This code fails to compile using g++ 4.2.1 but works fine under vc++ v8.

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.