Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I know it might be awkward to ask this type of question but really this bug is causing a lot of problem for me. I used the cpp mathematical parsing code from this link. C++ Implementation of Basic Expression Parser
http://www.technical-recipes.com/2011/a-mathematical-expression-parser-in-java-and-cpp/[^]

Now I first compiled the code in Dev c++ . It compiled perfectly and I got the desired output
But when I created a visual c++ win32 console application and used the above code and I got the following errors

XML
[02/09/14 6:07:39 pm] GAURAV LUTHRA: Error 1 error C2664: 'std::pair<int,int> std::make_pair<int,int>(_Ty1 &&,_Ty2 &&)' : cannot convert argument 2 from 'const int' to 'int &&' c:\users\linchpin66\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp 25 1 ConsoleApplication4
[02/09/14 6:09:21 pm] GAURAV LUTHRA: Error 2 error C2440: '<function-style-cast>' : cannot convert from 'const char [2]' to 'std::pair<const _Kty,_Ty>' c:\users\linchpin66\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp 25 1 ConsoleApplication4
[02/09/14 6:09:31 pm] GAURAV LUTHRA: Error 3 error C2664: 'std::pair<int,int> std::make_pair<int,int>(_Ty1 &&,_Ty2 &&)' : cannot convert argument 2 from 'const int' to 'int &&' c:\users\linchpin66\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp 26 1 ConsoleApplication4
[02/09/14 6:09:45 pm] GAURAV LUTHRA: Error 4 error C2440: '<function-style-cast>' : cannot convert from 'const char [2]' to 'std::pair<const _Kty,_Ty>' c:\users\linchpin66\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp 26 1 ConsoleApplication4
[02/09/14 6:09:52 pm] GAURAV LUTHRA: Error 5 error C1903: unable to recover from previous error(s); stopping compilation c:\users\linchpin66\documents\visual studio 2013\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp 26 1 ConsoleApplication4
[02/09/14 6:10:01 pm] GAURAV LUTHRA:  6 IntelliSense: no instance of function template "std::make_pair" matches the argument list
            argument types are: (int, const int) c:\Users\Linchpin66\Documents\Visual Studio 2013\Projects\ConsoleApplication4\ConsoleApplication4\ConsoleApplication4.cpp 25 26 ConsoleApplication4
[02/09/14 6:10:11 pm] GAURAV LUTHRA:  7 IntelliSense: no instance of function template "std::make_pair" matches the argument list
            argument types are: (int, const int) c:\Users\Linchpin66\Documents\Visual Studio 2013\Projects\ConsoleApplication4\ConsoleApplication4\ConsoleApplication4.cpp 26 24 ConsoleApplication4
[02/09/14 6:10:22 pm] GAURAV LUTHRA:  8 IntelliSense: no instance of function template "std::make_pair" matches the argument list
            argument types are: (int, const int) c:\Users\Linchpin66\Documents\Visual Studio 2013\Projects\ConsoleApplication4\ConsoleApplication4\ConsoleApplication4.cpp 27 24 ConsoleApplication4
[02/09/14 6:10:31 pm] GAURAV LUTHRA:  9 IntelliSense: no instance of function template "std::make_pair" matches the argument list
            argument types are: (int, const int) c:\Users\Linchpin66\Documents\Visual Studio 2013\Projects\ConsoleApplication4\ConsoleApplication4\ConsoleApplication4.cpp 28 24 ConsoleApplication4


I got around 9 errors. I know that there might be some library issues that visual studio uses. I am making a mathematical expression parsing app in windows. There somewhere it uses the snprintf() function which no longer exists in visual studio c library. Infact we have a _snprintf() function which doesn't provide the required functionality that I need and the app crashes in output.c file.

So how can we resolve this issue such that I can use the the snprintf() function in visual studio and how can we run the above code present in the link in win32 console app in Visual studio. I used visual studio 2012 and 2013. There are some more issues like arc4random doesn't work and we have to use rand and srand functions.

Searched a lot but unable to find the solution. Is it possible to change the compiler of my visual studio to C99 library where all these functions exist? Any help will be highly appreciated. Thanks
Posted
Updated 2-Sep-14 2:44am
v2
Comments
Richard MacCutchan 2-Sep-14 8:53am    
Why not ask the person who wrote the code?
Also, there is no point in posting error messages unless you show also the code where the error occurs.

The is an option in the project settings to change the compiler to a special C-Version.

Errors like that "cannot convert argument 2 from 'const int' to 'int" should be easy fixable.

This looks somehow strange: std::make_pair<int,int>(_Ty1 &&,_Ty2 &&)'. Reference to a reference in a constructor? My rule is in a constructor "I construct something" so I makes copies...

Do you understand what your are "writing"? ;-)
 
Share this answer
 
Comments
Stefan_Lang 2-Sep-14 10:23am    
It's not reference to reference, that is the C++11 move constructor syntax.
KarstenK 2-Sep-14 11:12am    
call me "rusty" - I am today shipping with VS 2008. After that release I upgrade my code to VS 2010. ;-)
Stefan_Lang 3-Sep-14 2:05am    
Gott to correct myself, std::make_pair is not a constructor, so this is not a move constructor, the double & is still a move reference, i. e. an object that passes ownership to the function being called.
KarstenK 3-Sep-14 4:00am    
you dont pass ownership by reference. :-O

Instead of a "heavy copy" only the original object reference is assigned. It diminishes copying stuff around.

If I you some "&" syntax I hardly code "const <t>&" to NEVER EVER manipulate it.
Stefan_Lang 3-Sep-14 5:33am    
Ok, i didn't express myself well. Might not have been a good idea to wrap it up in half a sentence, where current articles cover many pages:
http://www.cprogramming.com/c++11/rvalue-references-and-move-semantics-in-c++11.html
Try changing VS Project settings as below and see if this can help?

Configuration Properties
--Optimization
----Optimization: Disabled
--C/C++
----Precompiled Headers
------Precompiled Header: Turn Off Precompiled Header: Not using Precompiled Header
----Advanced
------CompileAs: Compile as C++ Code
--Linker
----General
------Enable Incremental Linking: No
 
Share this answer
 
v2
I created a Win32 console application in VS2010 and it worked just fine. All I did was copy the code from the site you linked and build the program.

The error messages hint at an issue with the make_pair implementation of VS2012/13 (which you said you are using), but I can't fathom for the life of me what it is they are doing wrong. The && types hint at move references, but why would the compiler pick an overload with move references for a POD type (int)?? Have you changed any settings that affect the use of the new C++11 features?

P.S.: you hinted at other code, i. e. that you have integrated the parser in your code. Are you sure it is the parser code that's causing the problem? Maybe it's some #define in your own code that messes with the parser code? Try not including any other header than those listed in the original code and see if you can make it work.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900