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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:12:44+00:00 2026-06-14T11:12:44+00:00

I bought the source code for an Ogre Plugin (Particle Universe) which is (or

  • 0

I bought the source code for an Ogre Plugin (Particle Universe) which is (or should´ve been) written in platform independent C++. It comes with a Visual Studio solution which compiles just fine, but because my whole project is compiled with G++, I want to compile that library with G++ too. But for some reason a template declaration throws an error in G++. Here is the code snippet.

typedef Ogre::Any Any;
template <typename ValueType> ValueType* any_cast(Any* operand) : public any_cast(operand){};

Is any C++ guru able to tell me why this error shows up? (maybe different syntax?)

include/ParticleUniverseAny.h: In function 'ValueType*
ParticleUniverse::any_cast(ParticleUniverse::Any*)':
include/ParticleUniverseAny.h:21:68: error: only constructors take member initializers
include/ParticleUniverseAny.h:21:68: error: expected identifier before 'public'
include/ParticleUniverseAny.h:21:68: error: expected '{' before 'public'
include/ParticleUniverseAny.h: At global scope:
include/ParticleUniverseAny.h:21:68: error: expected unqualified-id before 'public'

I would be happy and thankful for any help!

EDIT:
any_cast is defined in OgreAny.h

friend ValueType * any_cast(Any *);

template<typename ValueType>
ValueType * any_cast(Any * operand)
{
    return operand && operand->getType() == typeid(ValueType)
                ? &static_cast<Any::holder<ValueType> *>(operand->mContent)->held
                : 0;
}

template<typename ValueType>
ValueType * any_cast(Any * operand)
{
    return operand && operand->getType() == typeid(ValueType)
                ? &static_cast<Any::holder<ValueType> *>(operand->mContent)->held
                : 0;
}

template<typename ValueType>
const ValueType * any_cast(const Any * operand)
{
    return any_cast<ValueType>(const_cast<Any *>(operand));
}

template<typename ValueType>
ValueType any_cast(const Any & operand)
{
    const ValueType * result = any_cast<ValueType>(&operand);
    if(!result)
    {
        StringUtil::StrStreamType str;
        str << "Bad cast from type '" << operand.getType().name() << "' "
            << "to '" << typeid(ValueType).name() << "'";
        OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
            str.str(), 
            "Ogre::any_cast");
    }
    return *result;
}
  • 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-14T11:12:46+00:00Added an answer on June 14, 2026 at 11:12 am

    This code is complete nonsense:

    template <typename ValueType> ValueType* any_cast(Any* operand) : public any_cast(operand){};
    

    It looks like a template function definition with the:

    template <typename ValueType> ValueType* any_cast(Any* operand)
    

    part. But then there’s a colon, which is only legitimate in a constructor initialization list, followed by public, which is only legitimate in a class declaration. The two tokens : and public: simply can’t be present together like this.

    There must be some macro black magic going on here which makes in compile under MSVC and isn’t working under GCC. If so, this is a prime example of why macros can be evil. When misused, they result in a new secret language that nobody but the author knows.

    Unless you can get direct support from the library’s authors, you are likely up a creek with respect to getting this to compile under GCC.

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

Sidebar

Related Questions

I bought an RFID USB kit and haven't been able to read the RFID
Today I was reading code from some very popular numerical libraries written in FORTRAN
From the Android launcher source code, if ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) { //reset
I had recently stabilised developments of a major open source library written in Java.
If I don't modify source code and compile, I get Activity not started, its
I bought a SSL certificate through https://dnsimple.com/ for Heroku and got an email telling
I bought Crafting Rails Applications this weekend and noticed that the author uses bundle
I bought a server and I need to check it's internet connection (speed). Is
I bought the O'Reilly Dojo book by Matthew Russell. It says in your toolkit
I bought Delphi 1 when it came out - and was hooked. When BCB

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.