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 : 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;
}

Open in new window

IndarnavAsked:
Who is Participating?
 
Infinity08Connect With a Mentor Commented:
The error points to line 16 :

>>         static Count = 0;

and says :

>> missing type specifier - int assumed. Note: C++ does not support default-int

That's pretty clear ... You forgot to specify the type of the Count variable. Possibly int ?

        static int Count = 0;

Btw, why did you make it static ?
0
 
IndarnavAuthor Commented:
tell me the best then, i can change if it does not affect the code...
0
 
Infinity08Commented:
I did ... in my previous code.

What's still unclear ?
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
IndarnavAuthor Commented:
>>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?
0
 
Infinity08Commented:
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.
0
 
IndarnavAuthor Commented:
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.
0
 
Infinity08Commented:
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
0
 
IndarnavAuthor Commented:
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\Administrator\Desktop\restart\restart\restart\Release\BuildLog.htm"
1>restart - 0 error(s), 4 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
0
 
IndarnavAuthor Commented:
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..
0
 
Infinity08Commented:
In cmd, you don't double-click anything ... You simply type in the name of the executable, and press ENTER.
0
 
Infinity08Commented:
Ok, I've got to go do something now, but I'll be back in a short while.
0
 
IndarnavAuthor Commented:
i did the same way... i re tried in normal way too...
0
 
Infinity08Commented:
>> i did the same way...

And, did it run without error, and return you to the command prompt ?
0
 
itsmeandnobodyelseConnect With a Mentor Commented:
>>> .CRT section exists; there may be unhandled static initializers or terminators

That means you have some managed C++ parts included which hardly could work if the rest is unmanaged (normal) C++.

Note, managed C++ or C++ .NET is actually a new language which has some syntax rules in common with normal C++. There are (rather complex) ways from one to the other but you can't simply include header files from C++ .NET in C++ without spoiling the whole project.

From your code above I couldn't see where the wrong mix-up is. Maybe in stdafx.h.

The error message tells it is in cpu_disp module. If it is code from you, you should remove any references to managed C++ there.



0
 
IndarnavAuthor Commented:
Infinity08:

yes
0
 
Infinity08Commented:
>> Infinity08:
>> 
>> yes

So, what's the problem ? Your code ran without errors. What did you expect to happen ?
0
 
IndarnavAuthor Commented:
itsmeandnobodyelse:

what finally i do? code is here for ur ref.
0
 
IndarnavAuthor Commented:
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.
0
 
Infinity08Commented:
>> 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.
0
 
IndarnavAuthor Commented:
ok. let me check both again
0
 
IndarnavAuthor Commented:
i rechecked still same, not working on xp, on vista working fine..
0
 
Infinity08Commented:
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 ?
0
 
itsmeandnobodyelseCommented:
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
0
 
IndarnavAuthor Commented:
what is ide? how to run form there?
0
 
IndarnavAuthor Commented:
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..
0
 
Infinity08Commented:
>> 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.
0
 
itsmeandnobodyelseCommented:
>>> 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).
0
 
IndarnavAuthor Commented:
oh, but my vs is installed on vista, not xp.
0
 
itsmeandnobodyelseConnect With a Mentor Commented:
>>>> more strange is it is running in normal xp

We now have servicepack 3 on xp. What is normal xp?

Are these two different computers? Or did you add service pack 1 to a 'normal' xp and it had run before and didn't run after update?

Note, if different computers you may have different applications installed which may have installed the missing dlls in the good case.
0
 
itsmeandnobodyelseCommented:
>>>> 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?
0
 
IndarnavAuthor Commented:
vs 2008
0
 
itsmeandnobodyelseConnect With a Mentor Commented:
Did you copy msvcr90.dll to the target computers?

Any vs2008 (== VC9) project would need that dll cause it contains enhancements of msvcrt.dll and msvcrt20.dll which are the basic libraries for C runtime functions.

If using MFC or any third libary product you would need to copy (install) the dlls for these as well. Same applies for the .NET environment.
0
 
IndarnavAuthor Commented:
i made exe with multi threaded option instead of multi threaded dll, so no need of those dlls
0
 
itsmeandnobodyelseCommented:
>>>> 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.
0
 
IndarnavAuthor Commented:
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
0
 
IndarnavAuthor Commented:
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"
0
 
IndarnavAuthor Commented:
i solved, thanks all.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.