Preprocessor to check function parameters

Previous topic - Next topic

FutureCow

I would like the preprocessor to check the right amount of parameters are being passed to functions and display an appropriate error message, rather than getting a somewhat cryptic error from the compiler.

eg. I have a function like follows
Code (glbasic) Select
function ProcessTimers: A, B
but call it with ProcessTimers(1234)

I would like an error message like
Quote"myfile.gbas"(158) error : wrong number of parameters passed to function ProcessTimers

Instead it gives the C code equivalent with DGInt's etc in it. eg :-
Quotetoo few arguments to function `DGInt __GLBASIC__::ProcessTimers(DGInt, DGInt)'

FutureCow

More particularly, the compiler errors reference gpc_tempx.cpp and not the actual gbas file, so I've got to go into the cpp file, find the filename of the gbas file from the top, then search through the gbas file until I find (manually) the line with the error.

If it was picked up by the preprocessor I could double click it and go straight to the error and it would be easily fixed.

Kitty Hello

Yikes!! It should. Please post an example where it doesn't.

FutureCow

I tried pasting the example code from the help page in to see if I could get that to fail - and the test code compiles with a syntax error on the line
FUNCTION MAX: a, b

I'm buggered if I can see anything wrong with it!

Moru


FutureCow

#5
I haven't been able to recreate the error yet, I will keep trying.

Please correct the example code for the Function command though.

* Function MAX needs to be renamed and the c=MAX(a,b) line changed accordingly (why doesn't the compiler give an error like "error : "MAX" already defined"?)
* In the "Title" function, the comments need "//" instead of "/"
* In the same function, the command "EXIT" needs to be replaced with the command "RETURN"
* If you don't comment out the first line "LOCAL a" you get the error
C:\glbasic\gpc_temp0.cpp: In function `int __GLBASIC__::__MainGameSub_()':
C:\glbasic\gpc_temp0.cpp:36: error: `a' is not a member of `__GLBASIC__'