Hi, the last days I tried to get it running again.
I've started from the beginning.
There are 2 approaches:
1. Changing everything in AHK to unicode (char -> WCHAR, strlen->wcslen, "text"->_T("text")... ... ...) that didn't run after linking. I had to change hundreds (!) of lines of code.
2. Now I've tried to change as less as I can (nevertheless there are lotslotslots of changes). After days it compiles but didn't run.
I've tried to run it in Microsoft PocketPC Emulator and it crashes when trying to allocate memory
Code:
if (Line::sMaxSourceFiles)
{
new_max = 2*Line::sMaxSourceFiles;
if (new_max > ABSOLUTE_MAX_SOURCE_FILES)
new_max = ABSOLUTE_MAX_SOURCE_FILES;
}
else
new_max = 10;
// For simplicity and due to rarity of every needing to, expand by reallocating the array.
// Use a temp var. because realloc() returns NULL on failure but leaves original block allocated.
//MSI char **realloc_temp = (char **)realloc(Line::sSourceFile, new_max*sizeof(char *)); // If passed NULL, realloc() will do a malloc().
char **realloc_temp = (char **)malloc(new_max*sizeof(char *)); // If passed NULL, realloc() will do a malloc().
if (!realloc_temp)
If new_max is 100 the realloc statement crashes. After changing it to 10 it worked.
Next crash:
After reading the first command from the ahk-file ParseAndAddLine is called.
Before the first statement is done the emulator crashes (just before the first {.
The this-pointer is null.
Code:
[Stack fault]: Thread=8dacd2cc Proc=8c247550 'AutohotkeyCE.exe'
AKY=00004001 PC=0002e030 RA=0002db84 BVA=1e100ba4 FSR=00000405
Unhandled exception at 0x0002e030 in AutohotkeyCE.exe: 0xC00000FD: Stack overflow.
Code:
ResultType Script::ParseAndAddLine(char *aLineText, ActionTypeType aActionType, ActionTypeType aOldActionType
, char *aActionName, char *aEndMarker, char *aLiteralMap, size_t aLiteralMapLength)
// Returns OK or FAIL.
// aLineText needs to be a string whose contents are modifiable (though the string won't be made any
// longer than it is now, so it doesn't have to be of size LINE_SIZE). This helps performance by
// allowing the string to be split into sections without having to make temporary copies.
{ <- crash
//#ifdef _DEBUG
// if (!aLineText || !*aLineText)
// return ScriptError("DEBUG: ParseAndAddLine() called incorrectly.");
//#endif
There are just a few calls in the stack, so there's no endless recursion
Code:
> AutohotkeyCE.exe!Script::LoadIncludedFile(char* aFileSpec = 0x00110130, bool aAllowDuplicateInclude = false, bool aIgnoreLoadFailure = false) Line: 1058, Byte Offsets: 0x90 C++
AutohotkeyCE.exe!Script::LoadFromFile(bool aScriptWasNotspecified = false) Line: 925, Byte Offsets: 0x368 C++
AutohotkeyCE.exe!WinMain(HINSTANCE__* hInstance = 0x2dacd50a, HINSTANCE__* hPrevInstance = 0x00000000, wchar_t* lpCmdLine = 0x1e10fed8, int nCmdShow = 5) Line: 216, Byte Offsets: 0x538 C++
AutohotkeyCE.exe!WinMainCRTStartup(HINSTANCE__* hInstance = CXX0065: Error: unable to obtain expression value, HINSTANCE__* hInstancePrev = 0x000eac78, unsigned short* lpszCmdLine = 0x00110130, int nCmdShow = 0) Line: 21, Byte Offsets: 0x38 C
0x03f87210
Perhaps the problem is the small memory in a PocketPC. But I almost know nothing about PocketPC-programming.
Does somebody have ideas?
Ciao
Micha
Edit:
I've found the following at
http://www.firstobject.com/dn_markwince.htm
Quote:
Embedded Visual C++ warning LNK1166 medica 10-Oct-2006
I'm testing your CMarkup 8.2 at the moment. When I compile my project with embedded visual c++ (Windows CE) I always get the warning:
Markup.obj : warning LNK1166: cannot adjust code at offset=0x00001000, rva=0x0001CCE4
Try the /Gy compiler option. If the warning remains, based on my googling the warning apparently means it would be necessary to rewrite large functions into multiple smaller ones for the code to work correctly on certain TI 925 chips due to a bug on those chips
I've tried the compiler switch /Gy, but 1 of the 4 messages remains. I fear that some functions must be rewritten.