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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:52:29+00:00 2026-06-16T20:52:29+00:00

This seems so simple that it shouldn’t be a problem, but I’m not seeing

  • 0

This seems so simple that it shouldn’t be a problem, but I’m not seeing it, so any help would be appreciated.

I have a function that takes a parameter, then uses that parameter in a template. The compiler (Visual C++ 2012) is generating a C4100 “Unreferenced Formal Parameter” warning…and this is annoying. I cannot see why it thinks the parameter is unreferenced.

#define FactoryRegister(f, T) \
{ \
    shared_ptr<FactoryCreator<T>> creator(new FactoryCreator<T>()); \
    f.instance().Register(#T, creator); \
    f.instance().Register(typeid(T).name(), creator); \
}

void FactoryRegister(hive::Factory& factory)
{
    FactoryRegister(factory, MyClass);
}

Compiling this generates: “warning C4100: ‘factory’ : unreferenced formal parameter”

I would have thought that “factory” is quite obviously referenced as its “instance()” function is called twice after macro expansion. I assume here that the code expands to:

void FactoryRegister(Factory& factory)
{
    shared_ptr<FactoryCreator<MyClass>> creator(new FactoryCreator<MyClass>());
    factory.instance().Register("MyClass", creator);
    factory.instance().Register(typeid(MyClass).name(), creator);
}

The code functions fine, its just throwing a warning that I don’t understand. Note that, in my actual code, the macro and the function are in different projects and different files, but they were included here together for simplicity.

  • 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-16T20:52:31+00:00Added an answer on June 16, 2026 at 8:52 pm

    Based on the instance name, it looks like factory might be a singleton, and instance is a static function. In that case, the value of factory is indeed never used, and you can instead call the function directly on the class, which is essentially what the compiler does anyway:

    Factory::instance().Register(...);
    

    Then you can remove the parameter entirely, and you’ll avoid the apparent compiler bug that conflates usage of the parameter with usage of the parameter’s value.

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

Sidebar

Related Questions

This seems like a simple problem: I have a WF4 activity that guides the
This seems simple but I've exhausted my Google search patience. I have a RelativeLayout
This seems simple but I can't figure it out. I receive post data in
This seems painfully simple, but I can't work out how to do it: I
This seems like a simple question, but it is difficult to search for. I
this seems like a simple enough question but I can't seem to find a
This seems like a simple question, but has proven to be difficult to find
I have some Clojure code that seems maddeningly simple and yet is throwing an
This seems like a simple question to ask but, is it generally a good
So I have this old code being used, that runs simple ExecuteNonQuery command for

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.