Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2005

Tip: Looking for answers? Try searching our database.

[bug]Vc7\include\yvals.h(18) : fatal error C1017: invalid integer constant expression

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
www.fruitfruit.com - 28 Oct 2005 09:40 GMT
The following code snippet can be build in VC 6.0, but failed in VC 2003.
//////////////save the following code in t.cpp
#define _MT
#define _WIN32_WINNT 0x0500
#include <iostream>
#include <process.h>
#include <windows.h>
#pragma comment(lib,"libcmt.lib")
__int64 Counter=0;
BOOL volatile stop_thread = FALSE;
void __cdecl BasicThreadProc( void* pArguments )
{
__int64* p = (__int64*)pArguments;
__int64& c = *p;
std::cout<< "In BasicThreadProc...\n" ;
while(!stop_thread)
 c +=1;
std::cout<<"result:";
char buf[32];
_i64toa(c, buf, 10);
std::cout<< buf;
std::cout<<std::endl;
}
int main()
{
_beginthread(BasicThreadProc,0,(void*)&Counter);
   HANDLE hTimer = NULL;
   LARGE_INTEGER liDueTime;
   liDueTime.QuadPart=-100000000;
   // Create a waitable timer.
   hTimer = CreateWaitableTimer(NULL, TRUE, "WaitableTimer");
SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, 0);
   WaitForSingleObject(hTimer, INFINITE);
CloseHandle(hTimer);
stop_thread = true;
getchar();
return 0;
}

I use the following file to build this cpp file
call "C:\Program Files\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT"
cl /TP "C:\Temp\t.cpp"
del "C:\Temp\t.obj"
pause

call "D:\Apps\vs2003\Vc7\bin\vcvars32.bat"
cl /TP "C:\Temp\t.cpp"
del "C:\Temp\t.obj"
pause
David Lowndes - 28 Oct 2005 14:01 GMT
>The following code snippet can be build in VC 6.0, but failed in VC 2003.

Failed how, what's the error?

Dave
Signature

MVP VC++ FAQ: http://www.mvps.org/vcfaq

www.fruitfruit.com - 29 Oct 2005 07:34 GMT
The error message is in the caption.
I can paste it again.
D:\Apps\vs2003\Vc7\include\yvals.h(18) : fatal error C1017: invalid integer
constant expression

Is there someone who is willing to give a try?

> >The following code snippet can be build in VC 6.0, but failed in VC 2003.
>
> Failed how, what's the error?
>
> Dave
David Lowndes - 29 Oct 2005 09:25 GMT
>Is there someone who is willing to give a try?

Holger obviously had and suggested that you don't define _MT in your
source code. It compiles OK if you do as he suggested or if you change
your code to:

#define _MT 1

Dave
Signature

MVP VC++ FAQ: http://www.mvps.org/vcfaq

www.fruitfruit.com - 29 Oct 2005 11:34 GMT
OK,  #define _MT 1 works happily.
It is my problem that "I don't have a copy of VC 7.1 here." stopped me from
further thinking.
Thank you all.

> >Is there someone who is willing to give a try?
>
[quoted text clipped - 5 lines]
>
> Dave
Holger Grund - 28 Oct 2005 14:15 GMT
> The following code snippet can be build in VC 6.0, but failed in VC 2003.
> //////////////save the following code in t.cpp
> #define _MT
You shouldn't define _MT. Use the compiler switches /MT(d) ot /MDd

I don't have a copy of VC 7.1 here. But I guess the MS DW config
header yvals.h defines _MULTI_THREAD as _MT or uses
an #if _MT.

The compiler will define _MT to 1.

-hg
www.fruitfruit.com - 29 Oct 2005 07:36 GMT
I know how to set the compiler options, but I want to compile the file in
command line.
In fact I wrote a shell extension to build a single CPP file with VC6/VC7.
So I want to avoid creating a project for a single CPP file.

>> The following code snippet can be build in VC 6.0, but failed in VC 2003.
>> //////////////save the following code in t.cpp
[quoted text clipped - 8 lines]
>
> -hg

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.