Login Page - Create Account

Support Board


Date/Time: Sat, 15 May 2021 11:45:55 +0000



[Programming Help] - std::map is causing CPU exception

[2021-04-19 02:03:21]
User641030 - Posts: 11 | Ending Date: 2021-06-11
Hi,

I'm on SC version 2245 64-bit.

I'm writing a custom study that creates a simple map inside a class. The map insert method is throwing a warning: The custom dll 'name...' has just caused a CPU exception. It does not proceed after the warning.

I'm using Visual studio 2019 16.9.4 to build it locally.

I've pasted snippets of code relevant to the issue:

############## Creating object in sc.SetDefaults #################

TestClass* testObj= (TestClass*)sc.GetPersistentPointer(1);

if (testObj == NULL){
testObj = (TestClass*) new TestClass;
if( testObj != NULL)
sc.SetPersistentPointer(1, testObj);
else
return;
}

testObj.inputValue(1.0, 1.0)


########## TestClass #########

class TestClass{
std::map<float, float> testMap;

public:
TestClass();
void inputValue(SCStudyInterfaceRef sc, float low, float high);
}

In an instance method, I insert values into the Map

void TestClass::inputValue(SCStudyInterfaceRef sc, float low, float high){
testMap.insert(std::pair<float, float>(low, high));
}

Any help is much appreciated.

Thank you
[2021-04-19 02:30:14]
User641030 - Posts: 11 | Ending Date: 2021-06-11
I tried the Sierra remote build and it works fine.

It is something to do with my Visual Studio setup. I referred to older messages and documentation and configured my environment based on that.

Building remotely would mean I have to copy my individual files to the root of ACS_Source from my project directory. I don't see a way to multi-select files that are inside the sub-folders of ACS_Source.

What configuration issue can potentially lead to such problems?
[2021-04-20 05:54:43]
Flipper_2 - Posts: 51 | Ending Date: 2021-05-06 [Expired]
Not sure if this is your only problem but,

https://stackoverflow.com/questions/19164757/why-does-c-have-a-after-a-class-declaration?noredirect=1&lq=1
[2021-04-20 18:39:45]
User641030 - Posts: 11 | Ending Date: 2021-06-11
Flipper_2, This is not a syntax issue but a runtime issue. Otherwise, Sierra's remote build wouldn't work.
[2021-04-21 06:50:44]
User907968 - Posts: 493 | Ending Date: 2021-06-09
############## Creating object in sc.SetDefaults #################

Don't do this, refer - https://www.sierrachart.com/index.php?page=doc/ACSILProgrammingConcepts.html#DynamicMemoryAllocations

Also read - https://www.sierrachart.com/index.php?page=doc/ACSILProgrammingConcepts.html#AllocatingMemoryForClasses

and
testObj.inputValue(1.0, 1.0)

should be
testObj->inputValue(1.0, 1.0)

but I guess that might just be a typo in the post.

I tried the Sierra remote build and it works fine.
I did read this, but when you buid in VS, why not build for debug and locate the cause of the exception using debugger?
[2021-04-25 02:29:48]
User641030 - Posts: 11 | Ending Date: 2021-06-11
testObj.inputValue is typo it is testObj->inputValue.

Is there a guide on how to set up VSS for doing builds?

I would like to build it like any regular DLL and use it. I'm missing something in the configuration. Any help will be highly appreciated. Thank you!
[2021-04-25 14:50:26]
bradh - Posts: 550 | Ending Date: 2021-06-13
Is there a guide on how to set up VSS for doing builds?

https://www.sierrachart.com/index.php?page=doc/StepByStepACSILDebugging.php

Important Info Here: https://www.sierrachart.com/SupportBoard.php?PostID=180504#P180504

To post a message in this thread, you need to login with your Sierra Chart account:

Login

Login Page - Create Account