|
|
Home » U++ Library support » U++ Core » Function.h: "expression cannot be used as a function"
Function.h: "expression cannot be used as a function" [message #49358] |
Wed, 31 January 2018 12:44  |
Giorgio
Messages: 218 Registered: August 2015
|
Experienced Member |
|
|
Hi folks,
I have an application developed on Windows platform, that compiles and works fine. Now I am in the process to port it on a linux platform. When I try to compile it with gcc, I get the following error: "expression cannot be used as a function" on line 17 of Function.h. I am using Ultimate++ 2017.2. It is unclear if the error is triggered by some code I wrote even if it shows up in that file. In the past I compiled the same program on linux using an older version of Ultimate++ and it compiled without problems.
Regards,
Gio
|
|
|
|
Re: Function.h: "expression cannot be used as a function" [message #49360 is a reply to message #49359] |
Wed, 31 January 2018 14:26   |
Giorgio
Messages: 218 Registered: August 2015
|
Experienced Member |
|
|
This is the complete output.
Note that /home/pi/MyApps/StatusDetector/AggiungiComm.cpp:149 is the last line of the file (and is blank).
----- CtrlLib ( GUI SSE2 GCC SHARED POSIX LINUX ) (1 / 19)
----- MySql ( GUI SSE2 NOMYSQL GCC SHARED POSIX LINUX ) (2 / 19)
----- SqlCtrl ( GUI SSE2 GCC SHARED POSIX LINUX ) (3 / 19)
----- Barcode ( GUI SSE2 GCC SHARED POSIX LINUX ) (4 / 19)
----- MyINI ( GUI SSE2 GCC SHARED POSIX LINUX ) (5 / 19)
----- PostgreSQL ( GUI SSE2 GCC SHARED POSIX LINUX ) (6 / 19)
----- CtrlCore ( GUI SSE2 GCC SHARED POSIX LINUX ) (7 / 19)
----- PdfDraw ( GUI SSE2 GCC SHARED POSIX LINUX ) (8 / 19)
----- Draw ( GUI SSE2 GCC SHARED POSIX LINUX ) (9 / 19)
----- plugin/bmp ( GUI SSE2 GCC SHARED POSIX LINUX ) (10 / 19)
----- RichText ( GUI SSE2 GCC SHARED POSIX LINUX ) (11 / 19)
----- Core ( GUI SSE2 GCC SHARED POSIX LINUX ) (12 / 19)
----- plugin/png ( GUI SSE2 GCC SHARED POSIX LINUX ) (13 / 19)
----- Sql ( GUI SSE2 GCC SHARED POSIX LINUX ) (14 / 19)
----- plugin/z ( GUI SSE2 GCC SHARED POSIX LINUX ) (15 / 19)
----- Report ( GUI SSE2 GCC SHARED POSIX LINUX ) (16 / 19)
----- CodeEditor ( GUI SSE2 GCC SHARED POSIX LINUX ) (17 / 19)
----- plugin/pcre ( GUI SSE2 GCC SHARED POSIX LINUX ) (18 / 19)
----- StatusDetector ( GUI SSE2 NOMYSQL MAIN GCC SHARED POSIX LINUX ) (19 / 19)
AggiungiComm.cpp
In file included from /home/pi/upp/uppsrc/Core/Core.h:304:0,
from /home/pi/MyApps/StatusDetector/StatusDetector.h:23,
from /home/pi/MyApps/StatusDetector/AggiungiComm.h:5,
from /home/pi/MyApps/StatusDetector/AggiungiComm.cpp:1:
/home/pi/upp/uppsrc/Core/Function.h: In instantiation of 'Res Upp::Function<Res(ArgTypes ...)>::Wr
apper<F>::Execute(ArgTypes ...) [with F = const char*; Res = void; ArgTypes = {}]':
/home/pi/MyApps/StatusDetector/AggiungiComm.cpp:149:1: required from here
/home/pi/upp/uppsrc/Core/Function.h:17:60: error: expression cannot be used as a function
virtual Res Execute(ArgTypes... args) { return fn(args...); }
^
/home/pi/upp/uppsrc/Core/Function.h:17:60: warning: return-statement with a value, in function ret
urning 'void' [-fpermissive]
/home/pi/upp/uppsrc/Core/Function.h: In instantiation of 'Res Upp::Function<Res(ArgTypes ...)>::Wr
apper<F>::Execute(ArgTypes ...) [with F = int; Res = void; ArgTypes = {}]':
/home/pi/MyApps/StatusDetector/AggiungiComm.cpp:149:1: required from here
/home/pi/upp/uppsrc/Core/Function.h:17:60: error: expression cannot be used as a function
/home/pi/upp/uppsrc/Core/Function.h:17:60: warning: return-statement with a value, in function ret
urning 'void' [-fpermissive]
/home/pi/upp/uppsrc/Core/Function.h: In instantiation of 'Res Upp::Function<Res(ArgTypes ...)>::Wr
apper<F>::Execute(ArgTypes ...) [with F = Upp::GateN<>; Res = void; ArgTypes = {}]':
/home/pi/MyApps/StatusDetector/AggiungiComm.cpp:149:1: required from here
/home/pi/upp/uppsrc/Core/Function.h:17:60: warning: return-statement with a value, in function ret
urning 'void' [-fpermissive]
StatusDetector: 1 file(s) built in (0:14.29), 14291 msecs / file, duration = 14305 msecs, parallel
ization 0%
There were errors. (0:14.48)
[Updated on: Wed, 31 January 2018 14:39] Report message to a moderator
|
|
|
|
|
Re: Function.h: "expression cannot be used as a function" [message #49377 is a reply to message #49362] |
Thu, 01 February 2018 10:47   |
Giorgio
Messages: 218 Registered: August 2015
|
Experienced Member |
|
|
mirek wrote on Wed, 31 January 2018 18:46
The problem will be around here:
/home/pi/MyApps/StatusDetector/AggiungiComm.cpp:149:1:
Can you show us a couple of lines around it? Or maybe the whole file, if possible.
This is the whole file. The line numbers differ from those in the log because I removed the comments. In the original file the line number 149 is the last line of the file and is blank.
#include "AggiungiComm.h"
AggiungiComm::AggiungiComm(MLav _mlav, char tipo)
{
String macchina = _mlav.GetMacchina();
CtrlLayoutOKCancel(*this, t_("Selezionare commessa e pezzatura"));
Add(strCommPezz.LeftPosZ(16, 148).TopPosZ(12, 19));
btnTrova <<= THISBACK1(ScanCommessa, macchina);
listaMetri <<= THISBACK(CambioPezzatura);
DisableFields();
strMacchina = macchina;
ok.Disable();
btnTrova.Ok();
if (tipo == 'B')
{
ok.Enable();
ok.Ok();
btnTrova.Normal().Disable();
strCommPezz <<= AsString(_mlav.lav_in_corso.COMM) + AsString(_mlav.lav_in_corso.FASE) + "1" ;
ScanCommessa(macchina);
}
}
void AggiungiComm::ScanCommessa(String macchina)
{
if (SplittaComm() > 0)
{
ok.Enable();
ok.Ok();
btnTrova.Normal().Disable();
} else {
PromptOK(t_("ATTENZIONE: commessa non trovata, effettuare di nuovo lo scan"));
CleanFields();
strMacchina = macchina;
}
}
void AggiungiComm::CleanFields()
{
strLav3A <<= Null;
strLav3B <<= Null;
strLav3C <<= Null;
strLav3D <<= Null;
strLav3Dbis <<= Null;
strMacchina <<= Null;
strCommPezz <<= Null;
listaMetri.Reset();
strCommPezz.SetFocus();
}
void AggiungiComm::DisableFields()
{
strLav3A.Disable();
strLav3B.Disable();
strLav3C.Disable();
strLav3D.Disable();
strLav3Dbis.Disable();
strMacchina.Disable();
strCommPezz.SetFocus();
}
int AggiungiComm::SplittaComm()
{
String ingresso = this->strCommPezz.GetData();
WString pulita = (WString)TrimBoth(ingresso);
pulita = pulita.Left(pulita.GetLength() - 1);
WString comm = pulita.Left(pulita.GetLength() - 2);
WString fas = pulita.Right(2);
strLav3A = comm;
strLav3B = fas;
strLav3C = db_data.ContaBobFatte(AsString(comm), AsString(fas)) + 1;
strLav3D = NULL;
strLav3Dbis = NULL;
int esiste_comm = db_data.ControllaCommessa(AsString(comm));
if (esiste_comm > 0)
{
if (fas == (WString)"90")
{
InserisciPezzature(AsString(comm), AsString(fas));
}
else {
vcodbob.resize(1);
vmtbob.resize(1);
std::fill(vcodbob.begin(), vcodbob.end(), "");
std::fill(vmtbob.begin(), vmtbob.end(), 0);
listaMetri = 0;
}
}
return esiste_comm;
}
void AggiungiComm::InserisciPezzature(String commessa, String fase)
{
std::vector<PEZZE_BOB> lista = db_data.TrovaPezzature(commessa, fase);
size_t dimensione = lista.size();
vcodbob.resize(dimensione);
vmtbob.resize(dimensione);
int m = 0;
for (size_t i=0; i<lista.size(); i++)
{
int num_bob = lista[i].PEZZE.N_BOB;
int k = 0;
for(int j = 0; j < num_bob; j++)
{
if (AsString(lista[i].PEZZE.BOB) == "777")
listaMetri.Set(m, m, t_(" Pezz. non prevista"));
else
listaMetri.Set(m, m, ( AsString(lista[i].PEZZE.MT) + "m - N: " + AsString(k+1) + " di " + AsString(num_bob)));
vcodbob[m] = lista[i].PEZZE.BOB;
vmtbob[m] = lista[i].PEZZE.MT;
if (k<lista[i].fatte) { listaMetri.DisableCase(m); }
k++;
m++;
}
k = 0;
}
listaMetri = m -1;
strLav3D.MaxLen(3);
strLav3D <<= "777" ;
strLav3Dbis = 0 ;
}
void AggiungiComm::CambioPezzatura()
{
strLav3D.MaxLen(3);
strLav3D <<= vcodbob[listaMetri] ;
strLav3Dbis = vmtbob[listaMetri] ;
}
|
|
|
|
Re: Function.h: "expression cannot be used as a function" [message #49379 is a reply to message #49378] |
Thu, 01 February 2018 11:16   |
Oblivion
Messages: 1202 Registered: August 2007
|
Senior Contributor |
|
|
Hello Giorgio,
Quote:
This is not clear to me: Gate is in Function.h (Core library of U++).
Because compiler is tracing back the error to its source. Event/Gate/Function are templates. Event and Gate are aliases for specialized Function templates. Basically, compiler has to go back to their declarations (in function.h) to inform you that it cannot instantiate them with the parameters you provided.
As Novo pointed out, there is probably an ill-defined Event/Gate/Function (or CALLBACK) in your code. Check your callbacks and verify their signatures (i.e., if they are taking correct parameters, returning the expected value types or just void.)
First check:
btnTrova <<= THISBACK1(ScanCommessa, macchina);
listaMetri <<= THISBACK(CambioPezzatura);
Are these callbacks defined correctly?
Then check other callbacks. E.g. look into StatusDetector.h, AggiungiComm.h (if you defined some callback there).
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Thu, 01 February 2018 11:51] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
Re: Function.h: "expression cannot be used as a function" [message #49389 is a reply to message #49388] |
Thu, 01 February 2018 18:05  |
Giorgio
Messages: 218 Registered: August 2015
|
Experienced Member |
|
|
mirek wrote on Thu, 01 February 2018 17:43Giorgio wrote on Thu, 01 February 2018 16:37mirek wrote on Thu, 01 February 2018 16:34
And what exectly is your compiler? (gcc --version)
Gcc (Raspbian 4.9.2-10) 4.9.2
That is quite old, but should work.
I did an apt update / apt upgrade a couple of days ago, so it should be the latest available for Raspbian.
mirek wrote on Thu, 01 February 2018 17:43
Can you compile theide?
Yes, it takes ages but it compiles; I made all the tests using theide on Raspbian.
mirek wrote on Thu, 01 February 2018 17:43
BTW, off-topic: What raspberry variant are you using? I have got PI2, I wanted to do some tests with that and it is crashing way to often for any serious work. Probably overheating.
I have a Raspberry Pi 3 Model B, slow in compiling but it succeeds, lightweight applications works well (this will be tested on a manufacturing environment, working 24/24 5 days a week).
|
|
|
Goto Forum:
Current Time: Sat Apr 26 20:35:41 CEST 2025
Total time taken to generate the page: 0.01967 seconds
|
|
|