Sign in to follow this  

c11 on different compilers wont compile

Recommended Posts

mainly i have problem with this line

if (Items[i].MenuOnClick != NULL) { ALOG("NOT NULL PROCEEDING ACTION"); Items[i].MenuOnClick(); foldall(); }

basically i cant compare std::function(void()) with NULL (Items[i].MenuOnClick != NULL)

 

 

 

I'm trying to make my engine multiplatform (android, windows) where eclipse compiles it perfectly (android), C++ Builder Berlin doesnt compile it and throws:

 

 

[bcc32c Error] drop_menu.h(483):
use of overloaded operator '!=' is ambiguous (with operand types 'std::function<void ()>' and 'int')
[spoiler]
  functional(588): candidate function [with _Fty = void ()]
  drop_menu.h(483): built-in candidate operator!=(int, int)
  sysvari.h(3476): candidate function
  drop_menu.h(483): built-in candidate operator!=(__int128, int)
  drop_menu.h(483): built-in candidate operator!=(int, unsigned __int128)
  drop_menu.h(483): built-in candidate operator!=(long long, int)
  drop_menu.h(483): built-in candidate operator!=(long, int)
  drop_menu.h(483): built-in candidate operator!=(float, int)
  drop_menu.h(483): built-in candidate operator!=(int, float)
  drop_menu.h(483): built-in candidate operator!=(int, double)
  drop_menu.h(483): built-in candidate operator!=(int, long double)
  drop_menu.h(483): built-in candidate operator!=(int, long)
  drop_menu.h(483): built-in candidate operator!=(int, long long)
  drop_menu.h(483): built-in candidate operator!=(long double, int)
  drop_menu.h(483): built-in candidate operator!=(int, __int128)
  drop_menu.h(483): built-in candidate operator!=(int, unsigned int)
  drop_menu.h(483): built-in candidate operator!=(int, unsigned long)
  drop_menu.h(483): built-in candidate operator!=(double, int)
  drop_menu.h(483): built-in candidate operator!=(int, unsigned long long)
  drop_menu.h(483): built-in candidate operator!=(unsigned int, int)
  drop_menu.h(483): built-in candidate operator!=(unsigned long, int)
  drop_menu.h(483): built-in candidate operator!=(unsigned long long, int)
  drop_menu.h(483): built-in candidate operator!=(unsigned __int128, int)
  drop_menu.h(483): built-in candidate operator!=(float, long long)
  drop_menu.h(483): built-in candidate operator!=(float, __int128)
  drop_menu.h(483): built-in candidate operator!=(float, unsigned int)
  drop_menu.h(483): built-in candidate operator!=(float, unsigned long)
  drop_menu.h(483): built-in candidate operator!=(float, unsigned long long)
  drop_menu.h(483): built-in candidate operator!=(float, unsigned __int128)
  drop_menu.h(483): built-in candidate operator!=(double, float)
  drop_menu.h(483): built-in candidate operator!=(double, double)
  drop_menu.h(483): built-in candidate operator!=(double, long double)
  drop_menu.h(483): built-in candidate operator!=(double, long)
  drop_menu.h(483): built-in candidate operator!=(double, long long)
  drop_menu.h(483): built-in candidate operator!=(double, __int128)
  drop_menu.h(483): built-in candidate operator!=(double, unsigned int)
  drop_menu.h(483): built-in candidate operator!=(double, unsigned long)
  drop_menu.h(483): built-in candidate operator!=(double, unsigned long long)
  drop_menu.h(483): built-in candidate operator!=(double, unsigned __int128)
  drop_menu.h(483): built-in candidate operator!=(long double, float)
  drop_menu.h(483): built-in candidate operator!=(long double, double)
  drop_menu.h(483): built-in candidate operator!=(long double, long double)
  drop_menu.h(483): built-in candidate operator!=(long double, long)
  drop_menu.h(483): built-in candidate operator!=(long double, long long)
  drop_menu.h(483): built-in candidate operator!=(long double, __int128)
  drop_menu.h(483): built-in candidate operator!=(long double, unsigned int)
  drop_menu.h(483): built-in candidate operator!=(long double, unsigned long)
  drop_menu.h(483): built-in candidate operator!=(long double, unsigned long long)
  drop_menu.h(483): built-in candidate operator!=(long double, unsigned __int128)
  drop_menu.h(483): built-in candidate operator!=(long, float)
  drop_menu.h(483): built-in candidate operator!=(long, double)
  drop_menu.h(483): built-in candidate operator!=(long, long double)
  drop_menu.h(483): built-in candidate operator!=(long, long)
  drop_menu.h(483): built-in candidate operator!=(long, long long)
  drop_menu.h(483): built-in candidate operator!=(long, __int128)
  drop_menu.h(483): built-in candidate operator!=(long, unsigned int)
  drop_menu.h(483): built-in candidate operator!=(long, unsigned long)
  drop_menu.h(483): built-in candidate operator!=(long, unsigned long long)
  drop_menu.h(483): built-in candidate operator!=(long, unsigned __int128)
  drop_menu.h(483): built-in candidate operator!=(long long, float)
  drop_menu.h(483): built-in candidate operator!=(long long, double)
  drop_menu.h(483): built-in candidate operator!=(long long, long double)
  drop_menu.h(483): built-in candidate operator!=(long long, long)
  drop_menu.h(483): built-in candidate operator!=(long long, long long)
  drop_menu.h(483): built-in candidate operator!=(long long, __int128)
  drop_menu.h(483): built-in candidate operator!=(long long, unsigned int)
  drop_menu.h(483): built-in candidate operator!=(long long, unsigned long)
  drop_menu.h(483): built-in candidate operator!=(long long, unsigned long long)
  drop_menu.h(483): built-in candidate operator!=(long long, unsigned __int128)
  drop_menu.h(483): built-in candidate operator!=(__int128, float)
  drop_menu.h(483): built-in candidate operator!=(__int128, double)
  drop_menu.h(483): built-in candidate operator!=(__int128, long double)
  drop_menu.h(483): built-in candidate operator!=(__int128, long)
  drop_menu.h(483): built-in candidate operator!=(__int128, long long)
  drop_menu.h(483): built-in candidate operator!=(__int128, __int128)
  drop_menu.h(483): built-in candidate operator!=(__int128, unsigned int)
  drop_menu.h(483): built-in candidate operator!=(__int128, unsigned long)
  drop_menu.h(483): built-in candidate operator!=(__int128, unsigned long long)
  drop_menu.h(483): built-in candidate operator!=(__int128, unsigned __int128)
  drop_menu.h(483): built-in candidate operator!=(unsigned int, float)
  drop_menu.h(483): built-in candidate operator!=(unsigned int, double)
  drop_menu.h(483): built-in candidate operator!=(unsigned int, long double)
  drop_menu.h(483): built-in candidate operator!=(float, float)
  drop_menu.h(483): built-in candidate operator!=(unsigned int, long)
  drop_menu.h(483): built-in candidate operator!=(unsigned int, long long)
  drop_menu.h(483): built-in candidate operator!=(unsigned int, __int128)
  drop_menu.h(483): built-in candidate operator!=(unsigned int, unsigned int)
  drop_menu.h(483): built-in candidate operator!=(unsigned int, unsigned long)
  drop_menu.h(483): built-in candidate operator!=(unsigned int, unsigned long long)
  drop_menu.h(483): built-in candidate operator!=(unsigned int, unsigned __int128)
  drop_menu.h(483): built-in candidate operator!=(unsigned long, float)
  drop_menu.h(483): built-in candidate operator!=(unsigned long, double)
  drop_menu.h(483): built-in candidate operator!=(unsigned long, long double)
  drop_menu.h(483): built-in candidate operator!=(float, double)
  drop_menu.h(483): built-in candidate operator!=(unsigned long, long)
  drop_menu.h(483): built-in candidate operator!=(unsigned long, long long)
  drop_menu.h(483): built-in candidate operator!=(unsigned long, __int128)
  drop_menu.h(483): built-in candidate operator!=(unsigned long, unsigned int)
  drop_menu.h(483): built-in candidate operator!=(unsigned long, unsigned long)
  drop_menu.h(483): built-in candidate operator!=(unsigned long, unsigned long long)
  drop_menu.h(483): built-in candidate operator!=(unsigned long, unsigned __int128)
  drop_menu.h(483): built-in candidate operator!=(unsigned long long, float)
  drop_menu.h(483): built-in candidate operator!=(unsigned long long, double)
  drop_menu.h(483): built-in candidate operator!=(unsigned long long, long double)
  drop_menu.h(483): built-in candidate operator!=(float, long double)
  drop_menu.h(483): built-in candidate operator!=(unsigned long long, long)
  drop_menu.h(483): built-in candidate operator!=(unsigned long long, long long)
  drop_menu.h(483): built-in candidate operator!=(unsigned long long, __int128)
  drop_menu.h(483): built-in candidate operator!=(unsigned long long, unsigned int)
  drop_menu.h(483): built-in candidate operator!=(unsigned long long, unsigned long)
  drop_menu.h(483): built-in candidate operator!=(unsigned long long, unsigned long long)
  drop_menu.h(483): built-in candidate operator!=(unsigned long long, unsigned __int128)
  drop_menu.h(483): built-in candidate operator!=(unsigned __int128, float)
  drop_menu.h(483): built-in candidate operator!=(unsigned __int128, double)
  drop_menu.h(483): built-in candidate operator!=(unsigned __int128, long double)
  drop_menu.h(483): built-in candidate operator!=(float, long)
  drop_menu.h(483): built-in candidate operator!=(unsigned __int128, long)
  drop_menu.h(483): built-in candidate operator!=(unsigned __int128, long long)
  drop_menu.h(483): built-in candidate operator!=(unsigned __int128, __int128)
  drop_menu.h(483): built-in candidate operator!=(unsigned __int128, unsigned int)
  drop_menu.h(483): built-in candidate operator!=(unsigned __int128, unsigned long)
  drop_menu.h(483): built-in candidate operator!=(unsigned __int128, unsigned long long)
  drop_menu.h(483): built-in candidate operator!=(unsigned __int128, unsigned __int128)
  sysvari.h(3490): candidate function

[/spoiler]

 

 I have no idea how to bypass that in C++ if theres a way of doing such

 

Share this post


Link to post
Share on other sites

thanks!

 

anyway can i compare nullptr to 0 like NULL to 0

 

i mean i i set something to nullptr can i check it by if (something == 0) ? would that be correct?

Yes, though you should be checking if( something == nullptr) - it makes it obvious that 'something' is a pointer.

Share this post


Link to post
Share on other sites

thanks!

anyway can i compare nullptr to 0 like NULL to 0

i mean i i set something to nullptr can i check it by if (something == 0) ? would that be correct?

You can, but why would you?

'nullptr' is more than just a self-descriptive keyword, it also gives you compiler-enforced type checking and disambiguation.

Share this post


Link to post
Share on other sites

Just as a note, std::function also implements operator bool() so it's also perfectly fine to write if (Items[i].MenuOnClick)  to check if MenuOnClick has been assigned a callable function

 

I personally prefer this style for checking if pointers in general points to "something". For normal pointers it works by boolean conversion, where nullptr (and the value 0) is converted into false.

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

Sign in to follow this