Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calculatorgui_impl.cpp changes for Windows compile #13

Closed
rgleason opened this issue Mar 6, 2018 · 4 comments
Closed

calculatorgui_impl.cpp changes for Windows compile #13

rgleason opened this issue Mar 6, 2018 · 4 comments

Comments

@rgleason
Copy link
Collaborator

rgleason commented Mar 6, 2018

Walter, the changes to the current version of calculatorgui_impl.cpp which are needed to allow Windows to compile are below.

I've compared the Linux version side by side with the Windows version (One of the commented out sections may not be needed to be commented out at Line 340.)

Is there a way to make this file cross compile with Windows and Linux?

The line numbers use the Linux version on your repository from calculatorgui_impl.cpp.

LINE 340 Comment out

Dlg::~Dlg()
{
    if (m_pFunctiondialog)
        m_pFunctiondialog->Destroy();
    m_pFunctiondialog = NULL;
}

LINE 351 Replace Existing MuParser lines with this

    MuParser.ClearConst();
	MuParser.DefineConst(WxString2StdString(_T("pi")), 3.141592653589793238462643);
	MuParser.DefineConst(WxString2StdString(_T("e")), 2.718281828459045235360287);
	MuParser.DefineConst(WxString2StdString(_T("dtr")), 0.0174532925199433);
    MuParser.SetVarFactory(facfun_type(AddVariable),&MuParser);

LINE 806 Comment out

/*
std::string Dlg::WxString2StdString(wxString wxString_in){
    return std::string(wxString_in.mb_str());
}
*/

LINE 810 Add

mu::string_type Dlg::WxString2StdString(wxString wxString_in){
	std::string s = wxString_in.mb_str();
	std::wstring ws;
	UTF82WC(s, ws);

	return mu::string_type(ws);
}

NOTE: Making these changes to the file results in Linux Compile Errors. Is there some way to program this to be cross compiling with both Windows and Linux? It would be a big help.

@SaltyPaws
Copy link
Owner

Previously I would go around this by running the bash script to change out the character. You can use ifdefs:

This would be the way to do it:
#ifdef linux
//linux code goes here
#elif _WIN32
// windows code goes here
#else

#endif

@rgleason
Copy link
Collaborator Author

rgleason commented Mar 6, 2018

Thanks, I git clone ..saltypaws\calculator and then made a new branch "cross-compile"
Then made those changes using the #ifdef 's
When I compiled I got 20 errors and I wonder if the #ifdefs are working.
I wonder if there is a good way to check.... maybe I comment out the Linus statements and run it.
I've attached the file below.

I'll try some more in the morning.

Build FAILED.

"C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\build\calculator_pi.vcxproj" (default target) (3) ->
(ClCompile target) ->
  C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\tchar.h(2498): warning C4005: '_T' : macro redefinition [C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\build\calcula
tor_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\calculatorgui_impl.cpp(500): warning C4800: 'wxChoice *' : forcing value to bool 'true' or 'false' (performance warning) [C:\User
s\Frederick\Documents\GitHub\calculator_SaltyPaws\build\calculator_pi.vcxproj]

"C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\build\calculator_pi.vcxproj" (default target) (3) ->
(ClCompile target) ->
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\calculatorgui_impl.cpp(365): error C2664: 'void mu::ParserBase::DefineConst(const mu::string_type &,mu::value_type)' : cannot con
vert argument 1 from 'std::string' to 'const mu::string_type &' [C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\calculatorgui_impl.cpp(366): error C2664: 'void mu::ParserBase::DefineConst(const mu::string_type &,mu::value_type)' : cannot con
vert argument 1 from 'std::string' to 'const mu::string_type &' [C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\calculatorgui_impl.cpp(367): error C2664: 'void mu::ParserBase::DefineConst(const mu::string_type &,mu::value_type)' : cannot con
vert argument 1 from 'std::string' to 'const mu::string_type &' [C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\calculatorgui_impl.cpp(580): error C2664: 'void mu::ParserBase::SetExpr(const mu::string_type &)' : cannot convert argument 1 fro
m 'std::string' to 'const mu::string_type &' [C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\calculatorgui_impl.cpp(588): error C2664: 'void mu::ParserBase::SetExpr(const mu::string_type &)' : cannot convert argument 1 fro
m 'std::string' to 'const mu::string_type &' [C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\calculatorgui_impl.cpp(747): error C2664: 'void mu::ParserBase::SetExpr(const mu::string_type &)' : cannot convert argument 1 fro
m 'std::string' to 'const mu::string_type &' [C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\calculatorgui_impl.cpp(753): error C2664: 'void mu::ParserBase::SetExpr(const mu::string_type &)' : cannot convert argument 1 fro
m 'std::string' to 'const mu::string_type &' [C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\calculatorgui_impl.cpp(831): error C2556: 'mu::string_type Dlg::WxString2StdString(wxString)' : overloaded function differs only
by return type from 'std::string Dlg::WxString2StdString(wxString)' [C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\calculatorgui_impl.cpp(831): error C2371: 'Dlg::WxString2StdString' : redefinition; different basic types [C:\Users\Frederick\Doc
uments\GitHub\calculator_SaltyPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\calculatorgui_impl.cpp(834): error C3861: 'UTF82WC': identifier not found [C:\Users\Frederick\Documents\GitHub\calculator_SaltyPa
ws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\muparser\muParserBytecode.cpp(104): error C2039: 'max' : is not a member of 'std' [C:\Users\Frederick\Documents\GitHub\calculator
_SaltyPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\muparser\muParserBytecode.cpp(104): error C3861: 'max': identifier not found [C:\Users\Frederick\Documents\GitHub\calculator_Salt
yPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\muparser\muParserBytecode.cpp(131): error C2039: 'max' : is not a member of 'std' [C:\Users\Frederick\Documents\GitHub\calculator
_SaltyPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\muparser\muParserBytecode.cpp(131): error C3861: 'max': identifier not found [C:\Users\Frederick\Documents\GitHub\calculator_Salt
yPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\muparser\muParserBytecode.cpp(368): error C2039: 'max' : is not a member of 'std' [C:\Users\Frederick\Documents\GitHub\calculator
_SaltyPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\muparser\muParserBytecode.cpp(368): error C3861: 'max': identifier not found [C:\Users\Frederick\Documents\GitHub\calculator_Salt
yPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\muparser\muParserBytecode.cpp(386): error C2039: 'max' : is not a member of 'std' [C:\Users\Frederick\Documents\GitHub\calculator
_SaltyPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\muparser\muParserBytecode.cpp(386): error C3861: 'max': identifier not found [C:\Users\Frederick\Documents\GitHub\calculator_Salt
yPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\muparser\muParserBytecode.cpp(414): error C2039: 'max' : is not a member of 'std' [C:\Users\Frederick\Documents\GitHub\calculator
_SaltyPaws\build\calculator_pi.vcxproj]
  C:\Users\Frederick\Documents\GitHub\calculator_SaltyPaws\src\muparser\muParserBytecode.cpp(414): error C3861: 'max': identifier not found [C:\Users\Frederick\Documents\GitHub\calculator_Salt
yPaws\build\calculator_pi.vcxproj]

    2 Warning(s)
    20 Error(s)


calculatorgui_impl.cpp.docx

@SaltyPaws
Copy link
Owner

I have made it work before. This is another example (https://blog.tartanllama.xyz/if-constexpr/)
enum class OS { Linux, Mac, Windows };

//Translate the macros to C++ at a single point in the application
#ifdef linux
constexpr OS the_os = OS::Linux;
#elif APPLE
constexpr OS the_os = OS::Mac;
#elif __WIN32
constexpr OS the_os = OS::Windows;
#endif

void do_something() {
//do something general

 if constexpr (the_os == OS::Linux) {
     //do something Linuxy
 }
 else if constexpr (the_os == OS::Mac) {
     //do something Appley
 }
 else if constexpr (the_os == OS::Windows) {
     //do something Windowsy
 }

 //do something general

}

@rgleason
Copy link
Collaborator Author

rgleason commented Mar 6, 2018

Thanks wally. Now closing this. opened another.

@rgleason rgleason closed this as completed Mar 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants