Indarnav
asked on
resolve following error
wrote folloeing code, when building, gives following error..
restart.cpp(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
restart.cpp(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
// restart.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <tchar.h>
#include <malloc.h>
#define NUM_EXE 2
int _tmain(int argc, _TCHAR* argv[])
{
TCHAR *names[NUM_EXE] = {_T("c:\\path1\\abs.exe"), _T("d:\\path1\\set.exe")};
PROCESS_INFORMATION pi[NUM_EXE];
static Count = 0;
memset(&pi, 0, sizeof(pi));
STARTUPINFO startUpInfo;
memset(&startUpInfo, 0, sizeof(startUpInfo));
startUpInfo.cb = sizeof(startUpInfo);
startUpInfo.wShowWindow = SW_SHOW;
startUpInfo.dwFlags = STARTF_USESHOWWINDOW;
for (int i = 0; i < NUM_EXE; i++)
{
int Result = CreateProcess(NULL,names[i], NULL, NULL, false, 0, NULL, NULL, &startUpInfo, pi+i);
if(Result != 0)
{
Count ++;
CloseHandle(pi[i].hThread);
}
}
const int t = Count;
HANDLE* hs = NULL;
int handlesize = sizeof(HANDLE);
hs = (HANDLE*)HeapAlloc(GetProcessHeap(), 0, handlesize*t);
PROCESS_INFORMATION* pi1;
int processinfoize = sizeof(PROCESS_INFORMATION);
pi1 = (PROCESS_INFORMATION*)HeapAlloc(GetProcessHeap(), 0, processinfoize*t);
TCHAR *names1[NUM_EXE];
int ArrInfo[NUM_EXE];
for (int i = 0, j =0; i < NUM_EXE; i++)
{
if(pi[i].hProcess != NULL)
{
hs[j] = pi[i].hProcess;
pi1[j] = pi[i];
names1[j] = names[i];
j++;
}
}
do
{
DWORD res = WaitForMultipleObjects(Count, hs, false, INFINITE);
if (res >= WAIT_OBJECT_0)
{
int iIndexOfFinished = res - WAIT_OBJECT_0;
if(iIndexOfFinished != -1)
{
CloseHandle(pi1[iIndexOfFinished].hProcess);
int iResult = CreateProcess(NULL, names1[iIndexOfFinished], NULL, NULL, false, 0, NULL, NULL, &startUpInfo, pi1 + iIndexOfFinished);
hs[iIndexOfFinished] = pi1[iIndexOfFinished].hProcess;
}
else
{
break;
}
}
} while(1);
return 0;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I did ... in my previous code.
What's still unclear ?
What's still unclear ?
ASKER
>>Btw, why did you make it static ?
i want to know what else i can make it other than static, so that it works better without affecting code?
i want to know what else i can make it other than static, so that it works better without affecting code?
Making it static seems pretty pointless in this case (unless I'm missing something, which is what I was asking about).
But it doesn't hurt either, so you can leave it.
Just add the "int" like I suggested.
But it doesn't hurt either, so you can leave it.
Just add the "int" like I suggested.
ASKER
ok, i did and exe has built successfully. but it is not running on xp sp1, can u suggest why so? no errors.. i am double clicking but it is not starting exes defined neither start itself.
Instead of double-clicking it, try opening a command prompt (Start > Run > "cmd"), navigate to the directory that holds the executable, and call it. Something like :
cd C:\the\directory\
program.exe
cd C:\the\directory\
program.exe
ASKER
on built i got following warnings..
1>------ Build started: Project: restart, Configuration: Release Win32 ------
1>Compiling...
1>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
1>stdafx.cpp
1>Compiling...
1>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
1>restart.cpp
1>.\restart.cpp(48) : warning C4101: 'ArrInfo' : unreferenced local variable
1>Linking...
1>LIBCMT.lib(cpu_disp.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
1>Embedding manifest...
1>Build log was saved at "file://c:\Users\Administr ator\Deskt op\restart \restart\r estart\Rel ease\Build Log.htm"
1>restart - 0 error(s), 4 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
1>------ Build started: Project: restart, Configuration: Release Win32 ------
1>Compiling...
1>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
1>stdafx.cpp
1>Compiling...
1>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
1>restart.cpp
1>.\restart.cpp(48) : warning C4101: 'ArrInfo' : unreferenced local variable
1>Linking...
1>LIBCMT.lib(cpu_disp.obj)
1>Embedding manifest...
1>Build log was saved at "file://c:\Users\Administr
1>restart - 0 error(s), 4 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
ASKER
no running even from cmd.., when i double click processing symbol comes for a while and goes.. it seems as it starts and due to some error terminates immediately..
In cmd, you don't double-click anything ... You simply type in the name of the executable, and press ENTER.
Ok, I've got to go do something now, but I'll be back in a short while.
ASKER
i did the same way... i re tried in normal way too...
>> i did the same way...
And, did it run without error, and return you to the command prompt ?
And, did it run without error, and return you to the command prompt ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Infinity08:
yes
yes
>> Infinity08:
>>
>> yes
So, what's the problem ? Your code ran without errors. What did you expect to happen ?
>>
>> yes
So, what's the problem ? Your code ran without errors. What did you expect to happen ?
ASKER
itsmeandnobodyelse:
what finally i do? code is here for ur ref.
what finally i do? code is here for ur ref.
ASKER
when i call from cmd, it did not show any error but exe has not started runing. there is no exe in task manager with that name.. neither exe called any defined exes.
>> it did not show any error but exe has not started runing. there is no exe in task manager with that name..
Since there was no error message, it means that it DID run - it was just over too fast for you to notice it.
>> neither exe called any defined exes.
Well, there are several things to do to debug this :
(a) do the two executables "c:\\path1\\abs.exe" and "d:\\path1\\set.exe" exist ?
(b) try adding some error management code to catch runtime errors (by checking the return codes of each function call etc.), and show a message on stderr when a problem occurs.
Since there was no error message, it means that it DID run - it was just over too fast for you to notice it.
>> neither exe called any defined exes.
Well, there are several things to do to debug this :
(a) do the two executables "c:\\path1\\abs.exe" and "d:\\path1\\set.exe" exist ?
(b) try adding some error management code to catch runtime errors (by checking the return codes of each function call etc.), and show a message on stderr when a problem occurs.
ASKER
ok. let me check both again
ASKER
i rechecked still same, not working on xp, on vista working fine..
What did you recheck ? What did you do ? Did you add error checking code, and additional diagnostic output ? Do the two executables I mentioned exist ?
Did you try to run it from IDE? By clicking F5?
If yes, is the IDE on Vista or XP?
- Check the output window in XP case.
- Put a break point at any return statement if XP.
- If it breaks, check the conditions leading to the break point if XP
If yes, is the IDE on Vista or XP?
- Check the output window in XP case.
- Put a break point at any return statement if XP.
- If it breaks, check the conditions leading to the break point if XP
ASKER
what is ide? how to run form there?
ASKER
in vista i tested in normal way , by double clicking.. more strange is it is running in normal xp. but when i ran on xp sp1..it is not running..things are becoming more complicated..
>> in vista i tested in normal way , by double clicking..
Well, doing the same thing over and over won't change the behavior. Please read the suggestions we made earlier again, and try to follow them. They're needed to find out what the problem is exactly.
You're also not answering my questions for clarification, which makes it very difficult for me to help you.
Well, doing the same thing over and over won't change the behavior. Please read the suggestions we made earlier again, and try to follow them. They're needed to find out what the problem is exactly.
You're also not answering my questions for clarification, which makes it very difficult for me to help you.
>>> what is ide? how to run form there?
IDE is the Visual Studio where you edited the sources and where you make the builds (I assume).
IDE is the Visual Studio where you edited the sources and where you make the builds (I assume).
ASKER
oh, but my vs is installed on vista, not xp.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>>> oh, but my vs is installed on vista, not xp.
Hmmm. Vista has much more of the newer dlls already installed than xp.
What version of the Visual Studio you were running?
Hmmm. Vista has much more of the newer dlls already installed than xp.
What version of the Visual Studio you were running?
ASKER
vs 2008
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i made exe with multi threaded option instead of multi threaded dll, so no need of those dlls
>>>> i made exe with multi threaded option instead of multi threaded dll
There is not much difference (and not the difference you seem to assume). The multi threaded dll should be chosen for a dll project while the 'multi threaded' code generation is for applications. It has nothing to do which runtimes dlls were needed-
>>>> so no need of those dlls
You are wrong. The threading model only decides which C runtime dlls were used. In any case you need the VC runtime dlls which have modules for both multi-threaded and single-threaded. You may look with dependency walker (depends.exe) into your executable and surely will find a reference to msvcr90.dll.
The VC runtime dlls are msvcrt.dll, msvcrt20.dll,msvcrt40.dll and msvcrxx.dll where xx is the current version number of VC compiler - in your case msvcr90.dll. Only the last one is a matter of distribution (and change) while the others only rarely will be updated (by means of service packs not by active distribution) There are possibilities to reduce dependencies to these dlls but not for standard projects which always will need these dlls.
There is not much difference (and not the difference you seem to assume). The multi threaded dll should be chosen for a dll project while the 'multi threaded' code generation is for applications. It has nothing to do which runtimes dlls were needed-
>>>> so no need of those dlls
You are wrong. The threading model only decides which C runtime dlls were used. In any case you need the VC runtime dlls which have modules for both multi-threaded and single-threaded. You may look with dependency walker (depends.exe) into your executable and surely will find a reference to msvcr90.dll.
The VC runtime dlls are msvcrt.dll, msvcrt20.dll,msvcrt40.dll and msvcrxx.dll where xx is the current version number of VC compiler - in your case msvcr90.dll. Only the last one is a matter of distribution (and change) while the others only rarely will be updated (by means of service packs not by active distribution) There are possibilities to reduce dependencies to these dlls but not for standard projects which always will need these dlls.
ASKER
i opened the exe created with multi threaded ref. image 1, the dependecies shown by dependy waler are seen clearly. please have a look of image 1. also image 2 reffering to multi threaded dll, and now compare both images.
you can see image 2, exe is showing dependency on msvcr90.dll and also look at path from where it is running dll. (as commented by you).
so suggest me where to palce this dll in target pc? at sytem32 or same path as shown in image2.?
image-1-mt.jpg
image2--md.jpg
you can see image 2, exe is showing dependency on msvcr90.dll and also look at path from where it is running dll. (as commented by you).
so suggest me where to palce this dll in target pc? at sytem32 or same path as shown in image2.?
image-1-mt.jpg
image2--md.jpg
ASKER
i copied msvcr90.dll to system32 and made exe created with multi threaded dll, got following error...
" This application has failed to start because the application configuration is incorrect"
" This application has failed to start because the application configuration is incorrect"
ASKER
i solved, thanks all.
ASKER