c14 g++ + bionic compiler template comp error

Started by
9 comments, last by _WeirdCat_ 6 years, 3 months ago

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.

Advertisement

Probably going to need a little more context than that to divine the error. Do you have a minimal example you could link?

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

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

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.

 

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

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;
}


 

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.

Stephen M. Webb
Professional Free Software Developer

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

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);
  }

 

Stephen M. Webb
Professional Free Software Developer



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....

This topic is closed to new replies.

Advertisement