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. Dificulty ifintegrating an old C++ code into Visual C++

Dificulty ifintegrating an old C++ code into Visual C++

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharpvisual-studiohelpquestion
9 Posts 5 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.
  • T Offline
    T Offline
    taintransit
    wrote on last edited by
    #1

    I wrote a C++ code for analyzing texts few years ago and it works perfectly. I am now trying to make it a windows-based application by integrating it into Visual C++ using visual studio. This has been an ache! I first got fatal error C1010: Unexpected end of file while looking for precompiled header directive. It was not too difficult to correct this as there are many similar experiences recorded in various discussion groups on the Internet. However, when I added #include "stdafx.h" as directed in various responses to the c1010 error on the Internet, I got the following errors error C2095: syntax error: 'function-style cast' error C2226: syntax error: unexpected type 'T' error C2095: syntax error: ')' and a number of other similar errors. All these were generated by a code line 1 below: 1 template T max(T x, T,y) 2 { 3 return (x > y) ? x : y; 4 } any ideas on what could be wrong? taintransit

    C J D J 4 Replies Last reply
    0
    • T taintransit

      I wrote a C++ code for analyzing texts few years ago and it works perfectly. I am now trying to make it a windows-based application by integrating it into Visual C++ using visual studio. This has been an ache! I first got fatal error C1010: Unexpected end of file while looking for precompiled header directive. It was not too difficult to correct this as there are many similar experiences recorded in various discussion groups on the Internet. However, when I added #include "stdafx.h" as directed in various responses to the c1010 error on the Internet, I got the following errors error C2095: syntax error: 'function-style cast' error C2226: syntax error: unexpected type 'T' error C2095: syntax error: ')' and a number of other similar errors. All these were generated by a code line 1 below: 1 template T max(T x, T,y) 2 { 3 return (x > y) ? x : y; 4 } any ideas on what could be wrong? taintransit

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      Please, when posting code (and even more when posting template code), replace all the < and > symbols with the formatting tags just aboce the emoticons (otherwise, they won't be visisble). To your question: didn't you forget a class keyword ? template <class T> T max(T min, T max)


      Cédric Moonen Software developer
      Charting control [v1.2]

      D 1 Reply Last reply
      0
      • T taintransit

        I wrote a C++ code for analyzing texts few years ago and it works perfectly. I am now trying to make it a windows-based application by integrating it into Visual C++ using visual studio. This has been an ache! I first got fatal error C1010: Unexpected end of file while looking for precompiled header directive. It was not too difficult to correct this as there are many similar experiences recorded in various discussion groups on the Internet. However, when I added #include "stdafx.h" as directed in various responses to the c1010 error on the Internet, I got the following errors error C2095: syntax error: 'function-style cast' error C2226: syntax error: unexpected type 'T' error C2095: syntax error: ')' and a number of other similar errors. All these were generated by a code line 1 below: 1 template T max(T x, T,y) 2 { 3 return (x > y) ? x : y; 4 } any ideas on what could be wrong? taintransit

        J Offline
        J Offline
        James R Twine
        wrote on last edited by
        #3

        Unless > and < were eaten in your post, it looks like the syntax for the template is incorrect.  It should be something closer to:

        template< typename T >
        T max( T x, T y )

        Peace!

        -=- James
        Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
        Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
        See DeleteFXPFiles

        T 1 Reply Last reply
        0
        • C Cedric Moonen

          Please, when posting code (and even more when posting template code), replace all the < and > symbols with the formatting tags just aboce the emoticons (otherwise, they won't be visisble). To your question: didn't you forget a class keyword ? template <class T> T max(T min, T max)


          Cédric Moonen Software developer
          Charting control [v1.2]

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

          Cedric Moonen wrote:

          ...replace all the < and > symbols with the formatting tags...

          Hi Cedric. You actually only need to replace the < symbol.


          "A good athlete is the result of a good and worthy opponent." - David Crow

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          C 1 Reply Last reply
          0
          • D David Crow

            Cedric Moonen wrote:

            ...replace all the < and > symbols with the formatting tags...

            Hi Cedric. You actually only need to replace the < symbol.


            "A good athlete is the result of a good and worthy opponent." - David Crow

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            C Offline
            C Offline
            Cedric Moonen
            wrote on last edited by
            #5

            Oh well, then that makes things even more easier :) Thanks for the tip.


            Cédric Moonen Software developer
            Charting control [v1.2]

            1 Reply Last reply
            0
            • T taintransit

              I wrote a C++ code for analyzing texts few years ago and it works perfectly. I am now trying to make it a windows-based application by integrating it into Visual C++ using visual studio. This has been an ache! I first got fatal error C1010: Unexpected end of file while looking for precompiled header directive. It was not too difficult to correct this as there are many similar experiences recorded in various discussion groups on the Internet. However, when I added #include "stdafx.h" as directed in various responses to the c1010 error on the Internet, I got the following errors error C2095: syntax error: 'function-style cast' error C2226: syntax error: unexpected type 'T' error C2095: syntax error: ')' and a number of other similar errors. All these were generated by a code line 1 below: 1 template T max(T x, T,y) 2 { 3 return (x > y) ? x : y; 4 } any ideas on what could be wrong? taintransit

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

              taintransit wrote:

              1 template T max(T x, T,y)

              Look at this line closely.

              taintransit wrote:

              any ideas on what could be wrong?

              For a hint, try renaming the macro.


              "A good athlete is the result of a good and worthy opponent." - David Crow

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              1 Reply Last reply
              0
              • T taintransit

                I wrote a C++ code for analyzing texts few years ago and it works perfectly. I am now trying to make it a windows-based application by integrating it into Visual C++ using visual studio. This has been an ache! I first got fatal error C1010: Unexpected end of file while looking for precompiled header directive. It was not too difficult to correct this as there are many similar experiences recorded in various discussion groups on the Internet. However, when I added #include "stdafx.h" as directed in various responses to the c1010 error on the Internet, I got the following errors error C2095: syntax error: 'function-style cast' error C2226: syntax error: unexpected type 'T' error C2095: syntax error: ')' and a number of other similar errors. All these were generated by a code line 1 below: 1 template T max(T x, T,y) 2 { 3 return (x > y) ? x : y; 4 } any ideas on what could be wrong? taintransit

                J Offline
                J Offline
                jhwurmbach
                wrote on last edited by
                #7

                Stop! No! Don't try to precompile your C-Headers. Instead, switch off precompiled headers, either for the whole project (in the project properties) or for single files (in the properties of the file)


                Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal.
                George Orwell, "Keep the Aspidistra Flying", Opening words

                T 1 Reply Last reply
                0
                • J James R Twine

                  Unless > and < were eaten in your post, it looks like the syntax for the template is incorrect.  It should be something closer to:

                  template< typename T >
                  T max( T x, T y )

                  Peace!

                  -=- James
                  Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                  Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                  See DeleteFXPFiles

                  T Offline
                  T Offline
                  taintransit
                  wrote on last edited by
                  #8

                  Yes you are right. The angle brackets were eaten up in the post. Cedric Momen pointed this out in his response. jhwurmbach suggested that I avoid pre compiling the headers. It worked! Thanks every body. taintransit

                  1 Reply Last reply
                  0
                  • J jhwurmbach

                    Stop! No! Don't try to precompile your C-Headers. Instead, switch off precompiled headers, either for the whole project (in the project properties) or for single files (in the properties of the file)


                    Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal.
                    George Orwell, "Keep the Aspidistra Flying", Opening words

                    T Offline
                    T Offline
                    taintransit
                    wrote on last edited by
                    #9

                    Thanks a million jhwurmbach. You have just halted my one week of sleepless nights. Thanks also to David Crow, Cedric Moonen and James Twine for all your suggestions. taintransit

                    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