question

Frenk Gao avatar image
0 Likes"
Frenk Gao asked Frenk Gao commented

'beginOffset' : member function not declared in 'MyTaskExecuter' -mudule sdk

I am trying to Implementing Module DLLs (SDK-Documentation-ModuleDevelopment).

But there is always throw a error when I try to build my module dll (testmodel.dll in the Documentation) :

Error  1  error C2509: 'beginOffset' : member
function not declared in 'MyTaskExecuter'  \testmodule\mytaskexecuter.cpp  9  1  testmodule

And the source code:

_______________________

MyTaskExecuter.cpp

#include "MyTaskExecuter.h"
void MyTaskExecuter::bindVariables()
{
    TaskExecuter::bindVariables();
}
double MyTaskExecuter::beginOffset(double endspeed, treenode item)
{
    offsetloc[1] = 0;
    offsetloc[2] = 0;
    return beginOffsetDefault(endspeed, item);
}

_____________________________

MyTaskExecuter.h

#pragma once
#include "FlexsimDefs.h"
class MyTaskExecuter : public TaskExecuter
{
	virtual void bindVariables() override;
};

_____________________

testmodule.cpp

#include "testmodule.h"


visible ObjectDataType* createodtderivative(char* classname)
{
	if (strcmp(classname, "MyTaskExecuter") == 0) return new MyTaskExecuter;
	return NULL;
}


visible SimpleDataType* createsdtderivative(char* classname)
{
	return NULL;
}


visible void dllinitialize()
{


}


visible void dllcleanup()
{


}

testmodule.h

#pragma once

#include "FlexsimDefs.h"
#include "allobjects.h"

class MyTaskExecuter : public TaskExecuter
{
public:
	virtual void bindVariables(void);
	virtual double beginOffset(double endspeed, treenode item);
};
FlexSim 16.0.9
sdkmodule
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Steven Hamoen avatar image
1 Like"
Steven Hamoen answered Frenk Gao commented

@Frenk Gao You have declared your class twice (in your .h file and in testmodule.cpp) it should not be in testmodule only in .h But in your class declaration you should also include the begin offset like in the testmodule.cpp.

The reason you get the error is that the compiler tries to compile MyTaskexecuter.cpp and the only extra information it has it MyTaskexecuter.h because that is what you include. But in the .h file the beginoffset is not declared so that is exactly the error you get.

· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Frenk Gao avatar image Frenk Gao commented ·

Thank you!

When delete the testmodule.h 's code, it looks ok.

And also I should insert

#include "MyTaskExecuter.h"

in the testmodeule.cpp to include MyTaskExecuter Class.

But the Documentation do not tell me to do it. It's not friendly to a C++ rookie.

0 Likes 0 ·
Steven Hamoen avatar image Steven Hamoen Frenk Gao commented ·

@Frenk Gao May I suggest www.cplusplus.com for more information about C++

0 Likes 0 ·
Frenk Gao avatar image Frenk Gao Steven Hamoen commented ·

You are so nice!

Thank you for your suggestion!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.