Mail Archives: djgpp/1997/03/28/01:33:29
>Hi,
>Just a small question :
>assume,
>void foo(int x,int y)
>{
>// may I use here not x y names but somthing like arg1 and arg2 ?
>// For example :
> putpixel(arg1,arg2); //instead of putpixel(x,y)
>}
>(I'm using DJGPP v2.2)
If you don't mind using C++, You can try using references
to variables, like this:
---------------
#include <stdio.h>
void
foo (int a1, int a2)
{
int& a3 = a1;
int& a4 = a2;
fprintf (stderr, "%d, %d, %d, %d\n", a1, a2, a3, a4);
}
---------------
Check the result with gcc -O -S file.cc (it will produce assembler code in file.s).
Don't forget to use optimization, or else it would be like getting address of variable
and dereferencing it (see difference with gcc -S file.cc).
For C, you can try the following:
--------------------
void
foo (int a1, int a2)
{
#define a3 a1
#define a4 a2
fprintf (stderr, "%d, %d, %d, %d\n", a1, a2, a3, a4);
#undef a3
#undef a4
}
--------------------
But I don't recommend it. Just forger #undef a3 and in the rest of file
a3 will be replaced with a1. The best you can get is 'undefined variable a1',
the worst, assignment to a3 will assign to a1, which probably is not what you want.
>
>--
>Regards,
>Dim Zegebart, http://www.geocities.com/siliconvalley/pines/7817
>Moscow Russia.
- Raw text -