Support Board
Date/Time: Sun, 12 Jan 2025 11:46:29 +0000
Problem for linking two CPPs with an .H and compiling it
View Count: 812
[2017-02-13 10:10:57] |
User210074 - Posts: 63 |
Hello, I have an error message below. I do not know how to compile the 2 CPPs in DLL without this error Test.cpp #include <iostream> #include <string> #include "Root.h" #include "sierrachart.h" using namespace std; SCDLLName("Test") SCSFExport scsf_Test(SCStudyInterfaceRef sc) { SCSubgraphRef Red = sc.Subgraph[0]; if (sc.SetDefaults){ sc.GraphName = "Test 2 CPP"; sc.GraphRegion = 0; sc.AutoLoop = true; sc.FreeDLL = 1; Red.Name= "Red"; Red.DrawStyle = DRAWSTYLE_VALUE_ON_HIGH; Red.LineWidth = 1; Red.PrimaryColor = RGB(0,128,255); Red.DrawZeros = true; return; }//End defaults double A = 2.0f; double B = 3.0f; double C = 4.0f; double D = 5.0f; double E = 6.0f; double F = 7.0f; Mem(A, B, C, D, E, F); Red[sc.Index]=Mem; }//End Function Root.h #ifndef Root_H_INCLUDED #define Root_H_INCLUDED double Mem(double Z, double Y, double X, double W, double V, double U); #endif // Root_H_INCLUDED Mem.cpp #include <iostream> #include <vector> #include <string> #include "sierrachart.h" #include "Routeur.h" using namespace std; SCDLLName("Mem") SCSFExport scsf_Mem(SCStudyInterfaceRef sc) { if (sc.SetDefaults){return;}//end of defaults double Mem(double Z, double Y, double X, double W, double V, double U){ int const Size(5); int const Ini(0); vector <int> MemTab(Size); MemTab[Z] = Ini; MemTab[Y] = Ini; MemTab[X] = Ini; MemTab[W] = Ini; MemTab[V] = Ini; MemTab[U] = Ini; auto ResA = std::find(std::begin(MemTab), std::end(MemTab), Ini); if(ResA != std::end(MemTab)){return Size;} else{return Ini;} }//End of Mem }//End of Function Error C:\WINDOWS\system32\cmd.exe /C "C:\SierraChart\ACS_Source\VisualCCompile.Bat" C:\SierraChart\ACS_Source>call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" Test.cpp C:\SierraChart\ACS_Source\Test.cpp(28): error C2440: '=': cannot convert from 'double (__cdecl *)(double,double,double,double,double,double)' to 'float' C:\SierraChart\ACS_Source\Test.cpp(28): note: There is no context in which this conversion is possible -- End of Build -- 10:59:00 |
[2017-02-13 10:20:06] |
User210074 - Posts: 63 |
Oops I forget the good libraries Test.cpp #include <windows.h> #include <math.h> #include <iostream> #include <stdio.h> #include <string.h> #include <vector> #include <iomanip> #include <algorithm> #include <iterator> #include "sierrachart.h" using namespace std; SCDLLName("Test") SCSFExport scsf_Test(SCStudyInterfaceRef sc) { SCSubgraphRef Red = sc.Subgraph[0]; if (sc.SetDefaults){ sc.GraphName = "Test 2 CPP"; sc.GraphRegion = 0; sc.AutoLoop = true; sc.FreeDLL = 1; Red.Name= "Red"; Red.DrawStyle = DRAWSTYLE_VALUE_ON_HIGH; Red.LineWidth = 1; Red.PrimaryColor = RGB(0,128,255); Red.DrawZeros = true; return; }//End defaults double A = 2.0f; double B = 3.0f; double C = 4.0f; double D = 5.0f; double E = 6.0f; double F = 7.0f; Mem(A, B, C, D, E, F); Red[sc.Index]=Mem; }//End Function C:\WINDOWS\system32\cmd.exe /C "C:\SierraChart\ACS_Source\VisualCCompile.Bat" C:\SierraChart\ACS_Source>call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" Test.cpp C:\SierraChart\ACS_Source\Test.cpp(33): error C3861: 'Mem': identifier not found C:\SierraChart\ACS_Source\Test.cpp(34): error C2065: 'Mem': undeclared identifier -- End of Build -- 11:16:51 |
[2017-02-13 10:22:18] |
Sierra Chart Engineering - Posts: 104368 |
The problem is you have defined a function within a function. You cannot do that. You have done this in the Mem.cpp file. Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service: Sierra Chart Teton Futures Order Routing Date Time Of Last Edit: 2017-02-13 10:22:36
|
To post a message in this thread, you need to log in with your Sierra Chart account: