Convert code from VS6.0 to VC 1.52
-
Hi All, I have the following code which uses an argument list passed into a function, i get a pointer to the first argument and then set this pointer = to some modified argument. This in turn updates the arglist. See code below:
va_list arglist; // variable argument list va_start(arglist,cString); **char **Arg1 = &va_arg( arglist, char *);** *Arg1 = Arg1Modified;
I now have to convert this code to work after being compiled under VC 1.52. The line in bold above is the problem because in VC 1.52 you cannot declare variables on the same lin that they are used. Does anyone know how i need to declare the variable to work the same as it does in VS 6, i have tried:char **Arg1 Arg1 = &va_arg( arglist, char *);
but this does not work correctly. Thanks in Advance -
Hi All, I have the following code which uses an argument list passed into a function, i get a pointer to the first argument and then set this pointer = to some modified argument. This in turn updates the arglist. See code below:
va_list arglist; // variable argument list va_start(arglist,cString); **char **Arg1 = &va_arg( arglist, char *);** *Arg1 = Arg1Modified;
I now have to convert this code to work after being compiled under VC 1.52. The line in bold above is the problem because in VC 1.52 you cannot declare variables on the same lin that they are used. Does anyone know how i need to declare the variable to work the same as it does in VS 6, i have tried:char **Arg1 Arg1 = &va_arg( arglist, char *);
but this does not work correctly. Thanks in AdvanceKeithF wrote:
...in VC 1.52 you cannot declare variables on the same lin that they are used.
I went back and looked at some of my code from the early 90s (when v1.52c was being used). It's littered with examples to the contrary.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
KeithF wrote:
...in VC 1.52 you cannot declare variables on the same lin that they are used.
I went back and looked at some of my code from the early 90s (when v1.52c was being used). It's littered with examples to the contrary.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Hi David, Yes you are correct, sorry. What i meant to say is that i am using c files in VC 1.52 (maintenace project - no choice). It is with C files that this inline declaration is not allowed. Any ideas on how to solve the problem?
So what does the following produce:
char **Arg1;
Arg1 = &va_arg(arglist, char *);"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
So what does the following produce:
char **Arg1;
Arg1 = &va_arg(arglist, char *);"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Hi All, I have the following code which uses an argument list passed into a function, i get a pointer to the first argument and then set this pointer = to some modified argument. This in turn updates the arglist. See code below:
va_list arglist; // variable argument list va_start(arglist,cString); **char **Arg1 = &va_arg( arglist, char *);** *Arg1 = Arg1Modified;
I now have to convert this code to work after being compiled under VC 1.52. The line in bold above is the problem because in VC 1.52 you cannot declare variables on the same lin that they are used. Does anyone know how i need to declare the variable to work the same as it does in VS 6, i have tried:char **Arg1 Arg1 = &va_arg( arglist, char *);
but this does not work correctly. Thanks in AdvanceKeithF wrote:
char **Arg1 Arg1 = &va_arg( arglist, char *);
Shouldn't this be
char **Arg1
*****Arg1 = &va_arg( arglist, char *);Chris Meech I am Canadian. [heard in a local bar] Donate to help Conquer Cancer[^]
-
KeithF wrote:
char **Arg1 Arg1 = &va_arg( arglist, char *);
Shouldn't this be
char **Arg1
*****Arg1 = &va_arg( arglist, char *);Chris Meech I am Canadian. [heard in a local bar] Donate to help Conquer Cancer[^]
No, because
&va_arg()
returns achar **
, not achar *
."Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Hi All, I have the following code which uses an argument list passed into a function, i get a pointer to the first argument and then set this pointer = to some modified argument. This in turn updates the arglist. See code below:
va_list arglist; // variable argument list va_start(arglist,cString); **char **Arg1 = &va_arg( arglist, char *);** *Arg1 = Arg1Modified;
I now have to convert this code to work after being compiled under VC 1.52. The line in bold above is the problem because in VC 1.52 you cannot declare variables on the same lin that they are used. Does anyone know how i need to declare the variable to work the same as it does in VS 6, i have tried:char **Arg1 Arg1 = &va_arg( arglist, char *);
but this does not work correctly. Thanks in Advanceva_arg is a macro and the current code is depending on an implementation specific side effect. Somewhere in the back of mind, I recall this macro changing between 16 and 32-bit. If you have a bunch of code depending on Arg1 being a pointer to a pointer, you can do the following:
char* tmpArg1; char** Arg1; tmpArg1 = va_arg( arglist, char *); Arg1 = &tmpArg1;
The alternative is to bag the pointer to a pointer stuff and just use Arg1 as a char*.Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke