Dificulty ifintegrating an old C++ code into Visual C++
-
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
-
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
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] -
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
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 -
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]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
-
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
Oh well, then that makes things even more easier :) Thanks for the tip.
Cédric Moonen Software developer
Charting control [v1.2] -
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
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
-
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
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 -
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 DeleteFXPFilesYes 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
-
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 wordsThanks 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