in the last 20mins I did the following

1. Create a new DMD/LDC project

2. Added the code

import std.stdio;
import core.sys.windows.windows;
import std.array, std.conv;

int main(string[] argv)
{

        wchar* pCmd = cast(wchar*)to!wstring(argv.join(" ")).ptr;

        
    STARTUPINFO si;
    //ZeroMemory( &si, sizeof(si) );
    si.cb = si.sizeof;
    PROCESS_INFORMATION pi;
    //ZeroMemory(&pi, sizeof(pi));

    // Start the child process.
    BOOL result = CreateProcess
    (
        NULL, // No module name (use command line)
        pCmd, // Command line
        NULL, // Process handle not inheritable
        NULL, // Thread handle not inheritable
        FALSE, // Set bInheritHandles to FALSE
        DETACHED_PROCESS, // Detach process
        NULL, // Use parent's environment block
        NULL, // Use parent's starting directory
        &si, // Pointer to STARTUPINFO structure
        &pi // Pointer to PROCESS_INFORMATION structure (returned)
    );
    if (result) return 0;

    wchar[2048] msg;
    FormatMessage
    (
        FORMAT_MESSAGE_FROM_SYSTEM,
        null,
        GetLastError(),
        cast(uint)MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT),
        msg.ptr, cast(uint)2048,
        null
    );
        
    writeln(msg[0..lstrlen(msg.ptr)]);

    return -1;
}

3. Modified the command args in the options. Added cmd /c echo hello

4. Then went to debug it by putting a bp on the first line so I could check and ran it. Guess what? The program opened and closed. I've ran in to this problem before.

5. I added a bunch of bp's thinking it was just a problem with the first one(as that is how I get around it before).

6. Ran the program. Same thing. Ran the program. Same thing. I noticed that the bp's were turning white the split second the program was active.

hmmm... I then noticed the program was being built for x64.

7. I then changed it to x86 and voilĂ !

So, there is some issue with x64 and visual d's debugging in visual studio. That is the only file in the project. If it works on your system, keep trying until it doesn't!

Reply via email to