Jump to content
  • Advertisement
_WeirdCat_

C++ c14 g++ + bionic compiler template comp error

Recommended Posts

extern std::vector <std::string> w_nawiasie[10];

 

 

can someone tell me why I get compilation error like

 

/data/user/0/com.n0n3m4.droidc/files/temp.c:62:32: error: wrong number of template arguments (1, should be 2)
 extern std::vector <std::string> w_nawiasie[10];
                                ^
compilation terminated due to -Wfatal-errors.

Share this post


Link to post
Share on other sites
Advertisement

Im sorry but it seems thebproblem is way more than just thisbline of code, however i was trying to compile header only where i got cpp file where this extern is defined too i wish you could just erase this topic

Share this post


Link to post
Share on other sites

std::vector takes two parameters, but usually the second is set to a default of std::allocator. If the compiler is looking for a second parameter and you're using the default, try:
 

extern std::vector <std::string, std::allocator<std::string> > w_nawiasie[10];

 

Otherwise if you're using a custom allocator, use that instead.

 

Share this post


Link to post
Share on other sites

Yes indeed i need an allocator, thankfully theres one default already defined so i dont need to care about rhings that are uselessbfor me i just need working compiler on my phone

Share this post


Link to post
Share on other sites

A big stack of errors now i get

Quote

'bool betweenorequal(type2, type2, type)':
/mnt/ext_sdcard/WNB/DxcMath.h:157:4: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
 if (smallerA(x1,x2) <= x0)
    ^
/mnt/ext_sdcard/WNB/DxcMath.h: 

Where


template <class type> type  greaterA(type a, type b)
{
if (a==b) return a;
  if (a>b) return a; else return b;
}




template <class type> type  smallerA(type a, type b)
{
if (a==b) return a;
  if (a>b) return b; else return a;
}


/*
 * need strong optimization but first i need to check engine code
 */
template <class type, class type2> bool  betweenorequal(type2 x1, type2 x2, type x0)
{
bool result = false;
if (smallerA(x1,x2) <= x0)
if (greaterA(x1,x2) >= x0) result = true; else result = false;
return result;
}


 

Share this post


Link to post
Share on other sites

So... read the warning message.  Look at the code.  Read the warning message again and see how it applies to the the code.  Change the code to eliminate the problem described in the warning message, using the suggestion contained in the warning message.

Share this post


Link to post
Share on other sites

Ok this is actially my bad, i just couldn't imagine that this would compile with android ndk compile, but not with that compiler

Edited by WiredCat

Share this post


Link to post
Share on other sites

I'm afraid I can't even.  Could you possibly try rephrasing what you just typed?

By the way, your betweenorequal() could be simplified.

#include <algorithm>

template <class type, class type2>
  bool
  betweenorequal(type2 x1, type2 x2, type x0)
  {
  	return std::min(x1, x2) <= x0 && x0 <= std::max(x1, x2);
  }

 

Share this post


Link to post
Share on other sites

template <class type, class type2> bool  betweenorequal(type2 x1, type2 x2, type x0)
{
bool result = false;
type a = smallerA(x1,x2);
type b = greaterA(x1,x2);
if ( ( a <= x0 ) && ( b >= x0 ) )result = true; else result = false;

return result;
}

I did it like this, anyway your prevorious post pointed me that i should actually read carefully error msgs....

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!