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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:12:54+00:00 2026-05-14T06:12:54+00:00

I have some code that compiles and runs on MSVC++ but will not compile

  • 0

I have some code that compiles and runs on MSVC++ but will not compile on GCC. I have made a test snippet that follows. My goal was to move the static method from BFSMask to BFSMaskSized. Can someone explain what is going on with the errors (esp. the weird ‘operator<‘ error)? Thank you.

In the case of both #defines are 0, then the code compiles on GCC.

#define DOESNT_COMPILE_WITH_GCC     0
#define FUNCTION_IN_PARENT          0

I get errors if I change either #define to 1. Here are the errors I see.

#define DOESNT_COMPILE_WITH_GCC     0
#define FUNCTION_IN_PARENT          1
Test.cpp: In static member function 'static typename Snapper::BFSMask<T>::T_Parent::T_SINT Snapper::BFSMask<T>::Create_NEZ(TCMP)':
Test.cpp(492): error: 'CreateMaskFromHighBitSized' was not declared in this scope

#define DOESNT_COMPILE_WITH_GCC     1
#define FUNCTION_IN_PARENT          0
Test.cpp: In static member function 'static typename Snapper::BFSMask<T>::T_Parent::T_SINT Snapper::BFSMask<T>::Create_NEZ(TCMP) [with TCMP = int, T = int]':
Test.cpp(500):   instantiated from 'TVAL Snapper::BFWrappedInc(TVAL, TVAL, TVAL) [with TVAL = int]'
Test.cpp(508):   instantiated from here
Test.cpp(490): error: invalid operands of types '<unresolved overloaded function type>' and 'unsigned int' to binary 'operator<'

#define DOESNT_COMPILE_WITH_GCC     1
#define FUNCTION_IN_PARENT          1
Test.cpp: In static member function 'static typename Snapper::BFSMask<T>::T_Parent::T_SINT Snapper::BFSMask<T>::Create_NEZ(TCMP) [with TCMP = int, T = int]':
Test.cpp(500):   instantiated from 'TVAL Snapper::BFWrappedInc(TVAL, TVAL, TVAL) [with TVAL = int]'
Test.cpp(508):   instantiated from here
Test.cpp(490): error: invalid operands of types '<unresolved overloaded function type>' and 'unsigned int' to binary 'operator<'

Here is the code

namespace Snapper
{
#define DOESNT_COMPILE_WITH_GCC     0
#define FUNCTION_IN_PARENT          0

    // MASK TYPES
    // NEZ  - Not Equal to Zero
    #define BFSMASK_NEZ(A)      ( ( A ) | ( 0 - A ) )
    #define BFSELECT_MASK(MASK,VTRUE,VFALSE)    ( ((MASK)&(VTRUE)) | ((~(MASK))&(VFALSE)) )
    template<typename TVAL> TVAL BFSelect_MASK(TVAL MASK,TVAL VTRUE,TVAL VFALSE)
    { return(BFSELECT_MASK(MASK,VTRUE,VFALSE)); }

    //-----------------------------------------------------------------------------
    // Branch Free Helpers

    template<int BYTESIZE> struct BFSMaskBase {};
    template<> struct BFSMaskBase<2>
    {
        typedef UINT16  T_UINT;
        typedef SINT16  T_SINT;
    };
    template<> struct BFSMaskBase<4>
    {
        typedef UINT32  T_UINT;
        typedef SINT32  T_SINT;
    };
    template<int BYTESIZE> struct BFSMaskSized : public BFSMaskBase<BYTESIZE>
    {
        static const int SizeBytes      = BYTESIZE;
        static const int SizeBits       = SizeBytes*8;
        static const int MaskShift      = SizeBits-1;
        typedef typename BFSMaskBase<BYTESIZE>::T_UINT      T_UINT;
        typedef typename BFSMaskBase<BYTESIZE>::T_SINT      T_SINT;

#if FUNCTION_IN_PARENT
        template<int N> static T_SINT CreateMaskFromHighBitSized(typename BFSMaskBase<N>::T_SINT inmask);
#endif
    };

    template<typename T> struct BFSMask : public BFSMaskSized<sizeof(T)>
    {
        //  BFSMask = -1 (all bits set)

        typedef BFSMask<T>                      T_This;
        // "Import" the Parent Class
        typedef BFSMaskSized<sizeof(T)>         T_Parent;
        typedef typename T_Parent::T_SINT       T_SINT;

#if FUNCTION_IN_PARENT
        typedef T_Parent    T_MaskGen;
#else
        typedef T_This      T_MaskGen;
        template<int N> static T_SINT CreateMaskFromHighBitSized(typename BFSMaskSized<N>::T_SINT inmask);
#endif

        template<typename TCMP> static T_SINT Create_NEZ(TCMP A)
        {
            //ReDefineType(const typename BFSMask<TCMP>::T_SINT,SA,A);
            //const typename BFSMask<TCMP>::T_SINT cmpmask = BFSMASK_NEZ(SA);
            const typename BFSMask<TCMP>::T_SINT cmpmask = BFSMASK_NEZ(A);
#if DOESNT_COMPILE_WITH_GCC
            return(T_MaskGen::CreateMaskFromHighBitSized<sizeof(TCMP)>(cmpmask));
#else
            return(CreateMaskFromHighBitSized<sizeof(TCMP)>(cmpmask));
#endif
        }
    };

    template<typename TVAL> TVAL BFWrappedInc(TVAL x,TVAL minval,TVAL maxval)
    {
        const TVAL diff = maxval-x;
        const TVAL mask = BFSMask<TVAL>::Create_NEZ(diff);
        const TVAL incx = x + 1;
        return(BFSelect_MASK(mask,incx,minval));
    }

    SINT32 currentsnap = 0;
    SINT32 SetSnapshot()
    {
        currentsnap=BFWrappedInc<SINT32>(currentsnap,0,20);
        return(currentsnap);
    }
}
  • 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-14T06:12:55+00:00Added an answer on May 14, 2026 at 6:12 am

    Since CreateMaskFromHighBitSized doesn’t depend on the template parameter of the class it’s not a dependent name and the compiler expects to find it without looking at the templated base class. Therefore T_MaskGen:: has to be specified if the function should be found in the base class.

    When the name is explicitly qualified as T_MaskGen::CreateMaskFromHighBitSized it isn’t obvious to the compiler that this always will be a template. The template keyword is necessary to make that clear (in the same way typename is often used in these situations):

    return(T_MaskGen::template CreateMaskFromHighBitSized<sizeof(TCMP)>(cmpmask));
    

    This version of the call should work for both definitions of FUNCTION_IN_PARENT.

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

Sidebar

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.