QB64 Phoenix Edition
ERROR: C++ compilation failed. - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: ERROR: C++ compilation failed. (/showthread.php?tid=1123)



ERROR: C++ compilation failed. - Ed Davis - 11-15-2022

I'm getting:

Quote:QB64-PE Compiler V3.4.0

Beginning C++ output from QB64 code...
[..............................................    ] 92%
Beginning C++ output from QB64 code...
[..................................................] 100%

Compiling C++ code into EXE...
ERROR: C++ compilation failed.
Check .\internal\temp\compilelog.txt for details.
On:

Code: (Select All)
declare sub main
declare sub get_numeric_args(args() as double)

dim args(4) as double
get_numeric_args(args())

sub get_numeric_args(args() as double)
  args(1) = 123
end sub

compilelog.txt:

Quote:internal\c\c_compiler\bin\c++.exe -O2 -w -std=gnu++11 -DGLEW_STATIC -DFREEGLUT_STATIC -Iinternal\c\libqb/include -DDEPENDENCY_NO_SOCKETS -DDEPENDENCY_NO_PRINTER -DDEPENDENCY_NO_ICON -DDEPENDENCY_NO_SCREENIMAGE internal\c/qbx.cpp -c -o internal\c/qbx.o
In file included from internal\c/qbx.cpp:2529:
internal\c/..\\temp\\maindata.txt: In function 'void QBMAIN(void*)':
internal\c/..\\temp\\maindata.txt:13:2: error: 'pass1' was not declared in this scope
  pass1;
  ^~~~~
mingw32-make: *** [Makefile:412: internal\c/qbx.o] Error 1


maindata.txt
Code: (Select All)
if (!__ARRAY_DOUBLE_ARGS){
__ARRAY_DOUBLE_ARGS=(ptrszint*)mem_static_malloc(9*ptrsz);
new_mem_lock();
mem_lock_tmp->type=4;
((ptrszint*)__ARRAY_DOUBLE_ARGS)[8]=(ptrszint)mem_lock_tmp;
__ARRAY_DOUBLE_ARGS[4]= 0 ;
__ARRAY_DOUBLE_ARGS[5]=( 4 )-__ARRAY_DOUBLE_ARGS[4]+1;
__ARRAY_DOUBLE_ARGS[6]=1;
__ARRAY_DOUBLE_ARGS[0]=(ptrszint)mem_static_malloc(__ARRAY_DOUBLE_ARGS[5]*8);
memset((void*)(__ARRAY_DOUBLE_ARGS[0]),0,__ARRAY_DOUBLE_ARGS[5]*8);
__ARRAY_DOUBLE_ARGS[2]=1+2;
}
pass1;

main.txt
Code: (Select All)
S_0:;
do{

if(!qbevent)break;evnt(4);}while(r);
do{
SUB_GET_NUMERIC_ARGS(&(pass1=((double*)(__ARRAY_DOUBLE_ARGS[0]))[0]));
if(!qbevent)break;evnt(5);}while(r);
sub_end();
return;
}
void SUB_GET_NUMERIC_ARGS(ptrszint*_SUB_GET_NUMERIC_ARGS_ARRAY_DOUBLE_ARGS){
qbs *tqbs;
ptrszint tmp_long;
int32 tmp_fileno;
uint32 qbs_tmp_base=qbs_tmp_list_nexti;
uint8 *tmp_mem_static_pointer=mem_static_pointer;
uint32 tmp_cmem_sp=cmem_sp;
#include "data1.txt"
mem_lock *sf_mem_lock;
new_mem_lock();
sf_mem_lock=mem_lock_tmp;
sf_mem_lock->type=3;
if (new_error) goto exit_subfunc;
do{
tmp_long=array_check(( 1 )-_SUB_GET_NUMERIC_ARGS_ARRAY_DOUBLE_ARGS[4],_SUB_GET_NUMERIC_ARGS_ARRAY_DOUBLE_ARGS[5]);
if (!new_error) ((double*)(_SUB_GET_NUMERIC_ARGS_ARRAY_DOUBLE_ARGS[0]))[tmp_long]= 123 ;
if(!qbevent)break;evnt(8);}while(r);
exit_subfunc:;
free_mem_lock(sf_mem_lock);
#include "free1.txt"
if ((tmp_mem_static_pointer>=mem_static)&&(tmp_mem_static_pointer<=mem_static_limit)) mem_static_pointer=tmp_mem_static_pointer; else mem_static_pointer=mem_static;
cmem_sp=tmp_cmem_sp;
}
void SUB_VWATCH(){
qbs *tqbs;
ptrszint tmp_long;
int32 tmp_fileno;
uint32 qbs_tmp_base=qbs_tmp_list_nexti;
uint8 *tmp_mem_static_pointer=mem_static_pointer;
uint32 tmp_cmem_sp=cmem_sp;
#include "data2.txt"
mem_lock *sf_mem_lock;
new_mem_lock();
sf_mem_lock=mem_lock_tmp;
sf_mem_lock->type=3;
if (new_error) goto exit_subfunc;
exit_subfunc:;
free_mem_lock(sf_mem_lock);
#include "free2.txt"
if ((tmp_mem_static_pointer>=mem_static)&&(tmp_mem_static_pointer<=mem_static_limit)) mem_static_pointer=tmp_mem_static_pointer; else mem_static_pointer=mem_static;
cmem_sp=tmp_cmem_sp;
}

Thanks for any help!


RE: ERROR: C++ compilation failed. - SMcNeill - 11-15-2022

Remove the parenthesis from around args.

Code: (Select All)
declare sub main
declare sub get_numeric_args(args() as double)

DIM args(4) AS DOUBLE
get_numeric_args args()
PRINT args(1)


SUB get_numeric_args (args() AS DOUBLE)
    args(1) = 123
END SUB

It's a long standing glitch with arrays, and one that just happens to be a real PITA to track down and sort out. Wink


RE: ERROR: C++ compilation failed. - Ed Davis - 11-15-2022

(11-15-2022, 07:18 PM)SMcNeill Wrote: Remove the parenthesis from around args.
...
It's a long standing glitch with arrays, and one that just happens to be a real PITA to track down and sort out.  Wink

That fixed it!
Thanks!


RE: ERROR: C++ compilation failed. - mnrvovrfc - 11-16-2022

I was almost fooled by what's going on. In QuickBASIC the programmer who wanted to use parenthesis so much for a subprogram (not "FUNCTION") call must use "CALL" statement like this:

Code: (Select All)
CALL get_numeric_args(args())

In QB64(PE) don't use parenthesis around a parameter list for subprogram call. This is not C, it's easier than that. :tu: