lvdvelde
19th April 2004, 15:56
Hello everyone,
I've been busy programming libraries (dlls) and calling functions.
One of the dll's has to return multiple values - therefore I use reference arguments. In the function call, I use some table fields (for dll input) and some external declared variables for dll output.
Now the compiler comes up with some warnings:
Warning - external 'whatever' passed as reference to function ....
Is there a way to avoid these warnings or a better way to program the construction I described?
Lex
mark_h
19th April 2004, 15:59
I just use the -w flag when compiling when I get tired of seeing the warnings. I am not sure if there is a better way.
Mark
lvdvelde
19th April 2004, 16:24
Thanks Mark, I think you're right.
In the programmers manual I found out why - it's because the value of the reference argument is not changed until the call is returned. During the call, the value of the variable is not changed. OK, that all sounds logical - but the warning could also be:
Warning: your source may contain multiple nasty bugs!
Lex
lbencic
19th April 2004, 16:41
You can filter the warnings even more specifically, so you can filter out the 'External variable passed as reference' error, and still give you the warnings about the 'nasty bugs'. Try
-w9
to get rid of those warnings only.
Compiler Flags (http://www.baanboard.com/programmers_manual_baanerp_help_3gl_features_compiler)
just_fro
24th April 2004, 01:39
You get this warning because you use an externally defined variable as a reference variable.......
So the warning is really 'valid' (for once the compiler gives a usefull warning!)
You should avoid this by calling the function with local variables....
only the 'reffed' ones have to be be local......but in general it's nicer/better to use only locals in function calls.....why would you use them as arguments anyway when you have them external in the first place :D
lvdvelde
7th May 2004, 17:11
I've been thinking about your reply.
I am passing an external reference variable to my dll, because I want to display it's value on the form of the session. This value is calculated in the dll.
You're saying that (good programming practices?) I have to use a locally declared reference variable in the dll call, in which the dll stores the result, and after that I have to copy the value of this variable into an external variable to get it displayed.
Is that what you mean?
I understand that external declared variables can be changed outside the program script, but since this is not the case here, this all looks like more work which makes the script less clear.
But the warning makes some sense now.
Lex