From: bukinm AT inp DOT nsk DOT su (Michael Bukin) Newsgroups: comp.os.msdos.djgpp Subject: Re: function arguments aliases? Date: 28 Mar 1997 04:50:05 GMT Organization: BINP SD RAS Lines: 51 Message-ID: <5hfilt$4m6@sky.inp.nsk.su> References: <333AF42A DOT 4E59 AT post DOT comstar DOT ru> Reply-To: bukinm AT inp DOT nsk DOT su NNTP-Posting-Host: h-bukin.inp.nsk.su To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp >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 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.