MingGW GCC Compiler... Access violation at address 00000000

How to create strategies and indicators
Message
Author
PipCounter
Posts: 1
Joined: Sun Jan 05, 2014 6:03 pm
Location: United States

MingGW GCC Compiler... Access violation at address 00000000

#1 Postby PipCounter » Sun Jan 05, 2014 6:45 pm

I have an automated strategy that I coded up in C++ using the C++11 standard with the MinGW GCC compiler. I am wanting to use Forex Tester to backtest my automated strategy.

So, to learn about the API, I created a new project using the C++ strategies example for Forex Tester 2, which is the ObjectsTest strategy. After looking through the StrategyInterfaceUnit.h file, I discovered that I needed to include the windows.h header file, which MinGW does include so no problems there. I set up a header that exported the required functions as a C function (no name mangling), and then compiled the project. I did have to remove some of the defaults in the function call implementations, as the defaults were already included in the function declarations.

I then installed the strategy in Forex Tester 2, and then tried to run it. I get the following error:

"Error MainFormUnit.ProcessTick (SymbolList.AddSingleTick) Access violation at address 00000000. Read of address 00000000."

Seems to me that a pointer is pointing to the Null address...

I had a similar problem when trying out the example indicator...

Both examples export the IntrfProcsRec object. So I surrounded the Export as follows:

#ifdef __cplusplus
extern "C" {
#endif

EXPORT TInterfaceProcRec IntrfProcsRec;

#ifdef __cplusplus
}
#endif

To perform a C export (again, to avoid name mangling). This didn't help any, as I still get the same error.

Any suggestions?

KelvinHand
Posts: 103
Joined: Sun Jan 02, 2011 6:05 pm

#2 Postby KelvinHand » Sun Jan 05, 2014 10:35 pm

Hi,

1. Use free Visual C++ Express from microsoft site with less trouble and more people using. Also i think the code side is smaller then the rest of compilers.

2. Beware of 1 bug in the StrategyInterfaceUnit.h on Ver 1.11


//*** KH: This is OK in the declaration ***

// Delete all objects
// window - window where to delete
// ObjType - type of objects
void ObjectsDeleteAll(int window = 0, TObjectType ObjType = obj_AnyObject);


//*** KH: The implementation is not OK
//-----Delete all objects-----------------------------------------------------
void ObjectsDeleteAll(int window = 0, TObjectType ObjType = obj_AnyObject)
{
if (rec.pObjectsDeleteAll == NULL) return;
rec.ObjectsDeleteAll(rec.pObjectsDeleteAll, window, ObjType);
}


Remove the highlighted Red.


3. The Delphi version of StrategyInterfaceUnit.pas had more contents
then C++ StrategyInterfaceUnit.h



Check out and try out and see whether these help.


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 23 guests