Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Convert code from VS6.0 to VC 1.52

Convert code from VS6.0 to VC 1.52

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiohelp
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KeithF
    wrote on last edited by
    #1

    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

    D C J 3 Replies Last reply
    0
    • K KeithF

      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

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      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

      K 1 Reply Last reply
      0
      • D David Crow

        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

        K Offline
        K Offline
        KeithF
        wrote on last edited by
        #3

        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?

        D 1 Reply Last reply
        0
        • K KeithF

          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?

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          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

          K 1 Reply Last reply
          0
          • D David Crow

            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

            K Offline
            K Offline
            KeithF
            wrote on last edited by
            #5

            it produces this : âg it was supposed to be 342

            1 Reply Last reply
            0
            • K KeithF

              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

              C Offline
              C Offline
              Chris Meech
              wrote on last edited by
              #6

              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[^]

              D 1 Reply Last reply
              0
              • C Chris Meech

                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[^]

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                No, because &va_arg() returns a char **, not a 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

                1 Reply Last reply
                0
                • K KeithF

                  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

                  J Offline
                  J Offline
                  Joe Woodbury
                  wrote on last edited by
                  #8

                  va_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

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups