Search code examples
c++visual-studio-2008forkcreateprocesslptstr

error C3861: '_tcsdup': identifier not found


This is my first time and I'd like to make a parallel process using the windows CreateProcess function. Based on the example at MSDN I created a LPTSTR "(non-const) TCHAR string" command line argument like this

LPTSTR szCmdline[] = _tcsdup(TEXT("\C:\\MyProgram_linux_1.1\\MyProgram.exe") );

The LPTSTR and other char and string types are discussed here

The command line argument is passed to CreateProcess like this

if (!CreateProcess(NULL, szCmdline, /*...*/) ) cout << "ERROR: cannot start CreateProcess" << endl;

And these headers are present

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <strsafe.h>
#include <direct.h>

On compile this is the error:

error C3861: '_tcsdup': identifier not found

A search for this error found the same error but the solution was specific to using a .NET framework rather than explaining the error C3861: '_tcsdup'

Not sure if it related but there is also an error C2059: syntax error : ')' on the if (!CreateProcess(NULL, szCmdline, /*...*/) ) cout << "ERROR: cannot start CreateProcess" << endl;

How is this error fixed? And, what is going on with this?

Also, I am using the CreateProcess as a learning step towards learning the Linux fork() function - the Visual Studio interface is easier for me to use and once this is debugged and works, I will change to the g++ interface and change to fork() and debug from there - so a solution that leads to fork(), if possible, is the most beneficial.


Solution

  • Add the following include:

    #include <tchar.h>