Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Reggie

Pages: [1]
1
QB64 Discussion / Re: C++ Compilation failed passing arrays as parameters
« on: February 28, 2021, 11:47:01 am »
Thank you all for the responses!

(I'm brand new to QB64 -- looking for exciting stuff to do, this is my very first pandemic. The QB64 forum is certainly a lot more alive than I thought it might be -- please nobody take this the wrong way, but you have to admit that we are kind of at one of the extremities of the internet out here! Not unlike the Earth itself, a small but interesting outpost on the edge of the galaxy -- anything to get away from Javascript, amiright? ;-) )

==

Re: try3 is declared entirely wrong and used incorrectly.
Re: try2 is used incorrectly.

Reggie says:
True, but in both cases QB64 "fell down" into the C++ error, so I added them to the sample program while attempting to isolate the compiler bug:

[1] My assumption was/is that any such errors should be picked-up by QB64 proper, and that any fall-through to the internal C++ compiler is probably a reportable bug, regardless of the code that caused it to happen.

[2] I noticed the "Compilation failed" posting a few hours before mine, but the C++ error is different so they might be separate issues?

[3] When I first saw the error, I thought, "Weird, it's QBasic 4.5 compatible, but there's a C++ guy in there trying to get out!" (It was like watching the movie Aliens, quite frankly!)

==
Re: Also, don't call the sub like try1 (cloud()). Call it like try1 cloud()

Reggie says:
Okay...I see now, that's working much better...thanks!
But now I'm confused -- the example on QB64's "FUNCTION" page shows parentheses included in FUNCTION calls. Is it different for SUB calls? Or they are optional?
[Searching...this might be interesting...]

==
Re: When you don't put a type behind it then it expects a SINGLE type. Your array is declared as an INTEGER type.

Reggie says:
Okay...I think this probably explains the problem with the sample code itself...
I see here, from the QB64 documentation:

    When a variable has not been defined or has no type suffix, the value defaults to SINGLE.
    (http://qb64.org/wiki/INTEGER)

    Parameters passed after the procedure call must match the variable types in the SUB parameters in order.
    http://www.qb64.org/wiki/SUB

And so the problem (with my code) was a kind-of subtle combination of the above two conditions...

==
Reggie says:
And so just to confirm though, there is a relatively new or under-explored compiler bug involved here? (Fall-through to C++ error)


Thanks again for all the help!
Reg

2
QB64 Discussion / Re: C++ Compilation failed?
« on: February 28, 2021, 12:03:50 am »
C++ Compilation failed -- Code Sample:

Code: QB64: [Select]
  1. '==============================================================================
  2. ' QB64 Version 1.4 from git 0f49b2c
  3. '
  4. '   "C++ Compilation failed" Error,
  5. '   when trying to pass an array as a parameter.
  6. '
  7. '==============================================================================
  8.  
  9. '==============================================================================
  10. 'PS C:\Apps\qb64\internal\temp> .\recompile_win.bat
  11. 'Recompiling...
  12. 'In file included from qbx.cpp:2192:
  13. '..\\temp\\maindata.txt: In function 'void QBMAIN(void*)':
  14. '..\\temp\\maindata.txt:13:2: error: 'pass2' was not declared in this scope
  15. '  pass2;
  16. '  ^~~~~
  17. 'compilation terminated due to -Wfatal-errors.
  18. '==============================================================================
  19.  
  20.  
  21. ' Main
  22. PRINT "Main"
  23.  
  24. ' Declare the cloud() array
  25. CONST SIZE = 8
  26. DIM cloud(1 TO SIZE) AS INTEGER
  27.  
  28. ' Initialize the cloud() array
  29. DIM index AS INTEGER
  30. FOR index = 1 TO SIZE
  31.     cloud(index) = 0
  32.     PRINT "Index = "; index
  33.  
  34. ' Invoke Subroutines
  35. 'try1 (cloud()) ' Uncommenting this line generates C++ Compilation failure error
  36. 'try2 (cloud) ' Uncommenting this line generates C++ Compilation failure error
  37. 'try3 (cloud(3)) ' Uncommenting this line generates C++ Compilation failure error
  38.  
  39.  
  40. SUB try1 (cloud())
  41.     PRINT "Try1"; cloud(1)
  42.  
  43. SUB try2 (cloud())
  44.     PRINT "Try2"; cloud(2)
  45.  
  46. SUB try3 (cloud( 8))
  47.     PRINT "Try3"; cloud(3)
  48.  
  49.  

3
QB64 Discussion / C++ Compilation failed passing arrays as parameters
« on: February 27, 2021, 11:59:13 pm »
QB64 Version 1.4 from git 0f49b2c (Win10-x64):
"C++ Compilation failed" Error,  when trying to pass an array as a parameter.

(Code attached (same as in the next post below) -- uncommenting the "try" lines cause the internal compiler error)

Pages: [1]