473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

is it possible to programmatically detect Visual C++ 2005 SP1?

Is there some way I can do something like this
#if <running on Visual C++ 2005 SP1>
//SP1 code here
#else
//other code here
#endif
Jan 16 '07 #1
11 3896
Hi Jonathan!
Is there some way I can do something like this
#if <running on Visual C++ 2005 SP1>
//SP1 code here
#else
//other code here
#endif
Currently I don't see a way...
But: Why do nou need it?

Greetings
Jochen
Jan 16 '07 #2
Hi Bruno!
>Currently I don't see a way...

_MSC_VER ?
_MSC_VER is "1400" in both cases...

Greetings
Jochen
Jan 16 '07 #3
Microsoft has made some changes to the CxxUnhandledExceptionFilter logic in
Visual C++ 2005 SP1. Because of the way that my code (in a dll) is linked
to executable files compiled with Visual C++ 6 (and that I cant touch),
this change has broken my functionality that I have for dumping debug
information in the event of a crash. I have a workaround that makes it work
again with VS2005 SP1 but that only works on VS2005 SP1 and not on VS2005.
Hence the need to detect the difference :)
Jan 16 '07 #4
Microsoft has made some changes to the CxxUnhandledExceptionFilter logic
in Visual C++ 2005 SP1. Because of the way that my code (in a dll) is
linked to executable files compiled with Visual C++ 6 (and that I cant
touch), this change has broken my functionality that I have for dumping
debug information in the event of a crash. I have a workaround that makes
it work again with VS2005 SP1 but that only works on VS2005 SP1 and not on
VS2005. Hence the need to detect the difference :)
Hi,

I think I have found a way to do this at runtime, not compile time.
Basically, I looked in the list of resolved bugs to find anything simple
that could differentiate between RTM and SP1.
http://blogs.msdn.com/vcblog/archive...22/643325.aspx

I picked out this one:
http://connect.microsoft.com/VisualS...dbackID=101702

And made the following example:
char test[10];
if (sizeof(&test)==4)
cout << "SP1";
else
cout << "RTM";

With RTM, the sizeof is 10 instead of 4, so RTM is printed.
I would have tested it with SP1 before posting my reply here, but it is
still being installed. apparently, this can take a long, long time.
A quick test should provide you with the answer.
Combine my example with _MSC_VER and you can exactly see which version you
have compiled your app with.

I just used this bugfix to differentiate, but maybe if you search through
the complete list you may find something that can differentiate at compile
time.
Hope this helps. Let me know.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Jan 16 '07 #5

"Bruno van Dooren [MVP VC++]" <br**********************@hotmail.comwrote
in message news:uR**************@TK2MSFTNGP06.phx.gbl...
>Microsoft has made some changes to the CxxUnhandledExceptionFilter logic
in Visual C++ 2005 SP1. Because of the way that my code (in a dll) is
linked to executable files compiled with Visual C++ 6 (and that I cant
touch), this change has broken my functionality that I have for dumping
debug information in the event of a crash. I have a workaround that makes
it work again with VS2005 SP1 but that only works on VS2005 SP1 and not
on VS2005. Hence the need to detect the difference :)

Hi,

I think I have found a way to do this at runtime, not compile time.
Basically, I looked in the list of resolved bugs to find anything simple
that could differentiate between RTM and SP1.
http://blogs.msdn.com/vcblog/archive...22/643325.aspx

I picked out this one:
http://connect.microsoft.com/VisualS...dbackID=101702

And made the following example:
char test[10];
if (sizeof(&test)==4)
cout << "SP1";
else
cout << "RTM";

With RTM, the sizeof is 10 instead of 4, so RTM is printed.
I would have tested it with SP1 before posting my reply here, but it is
still being installed. apparently, this can take a long, long time.
A quick test should provide you with the answer.
Combine my example with _MSC_VER and you can exactly see which version you
have compiled your app with.

I just used this bugfix to differentiate, but maybe if you search through
the complete list you may find something that can differentiate at compile
time.
Since sizeof is a compile-time operator, that should be usable with
templates to select different code paths at compile time.

It won't look quite the same as preprocessor conditionals though.
Hope this helps. Let me know.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"


Jan 16 '07 #6
Hi Jonathan!
Is there some way I can do something like this
#if <running on Visual C++ 2005 SP1>
//SP1 code here
#else
//other code here
#endif
Yu could use the "_CRT_ASSEMBLY_VERSION" define...
But this only works if you do *not* define "_USE_RTM_VERSION"...

if (strcmp(_CRT_ASSEMBLY_VERSION, "8.0.50727.762") == 0)
_tprintf(_T("SP1\n"));
else
_tprintf(_T("RTM\n"));

Greetings
Jochen
Jan 17 '07 #7
Since sizeof is a compile-time operator, that should be usable with
templates to select different code paths at compile time.
Thanks to Ben who gave me the idea, I have created a compile time solution:

template <int iclass VcSelectorClass
{
public:
static char Dummy[10];
static void DoStuff(void)
{
//put code for VC2005 RTM here
cout << "RTM" << endl;
}
};

template <class VcSelectorClass<4>
{
public:
static void DoStuff(void)
{
//put code for VC2005 SP1 here
cout << "SP1" << endl;
}
};
//typedef for making things automatic without forcing you to type too much
garbage
typedef VcSelectorClass<sizeof(&VcSelectorClass<0>::Dummy) VcSelector;

int _tmain(int argc, _TCHAR* argv[])
{
//do stuff that depends on the compiler version.
VcSelector::DoStuff();
return 0;
}
It won't look quite the same as preprocessor conditionals though.
Nope. It is slightly more verbose :-)

_CRT_ASSEMBLY_VERSION is also different between RTM and SP1, but that is a
string and not usable with preprocessor conditionals.
_CPPLIB_VER is an integer, but I don't know if that changed or not.

Anyway, the above solution is a good way to impress your coworkers with
black magic C++ incantations. Just be sure to document why you are doing this.

--
Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"
Jan 17 '07 #8
The full version is conveniently named _MSC_FULL_VER
But note that versions for x86, x64 and IA32 may be different.

(sorry don't have SP1 at hand but maybe you can just take
any version number of 14.00.50727.42 as "SP1" )
I haven't checked it, but was told in the private ng by another MVP that it
is the same for both RTM and SP1.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Jan 19 '07 #9
This won't work on x64

It doesn't have to.
The problem occurrs specifically when his DLL is used with a VC6 exe that
cannot be changed or upgraded.
I.e. the problem only exists on 32 bit platforms.
On 64 bit platforms he can use the normal way of doing things without
needing the VC version detection.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Jan 19 '07 #10
Hi Pavel!
The full version is conveniently named _MSC_FULL_VER
But note that versions for x86, x64 and IA32 may be different.

(sorry don't have SP1 at hand but maybe you can just take
any version number of 14.00.50727.42 as "SP1" )
Exactly this is the problem: It has the *same* number for RTM and SP1!
It seems to be a "mistake".... but now it is too late ;-(

Greetiungs
Jochen
Jan 19 '07 #11

"Pavel A." <pa*****@NOwritemeNO.comwrote in message
news:42**********************************@microsof t.com...
This won't work on x64
The method will.

One template will use 10, the other will use sizeof (char*), which is 4 or
8. Easy to distinguish.
>
--PA
"Bruno van Dooren [MVP VC++]" wrote:
Since sizeof is a compile-time operator, that should be usable with
templates to select different code paths at compile time.

Thanks to Ben who gave me the idea, I have created a compile time
solution:

template <int iclass VcSelectorClass
{
public:
static char Dummy[10];
static void DoStuff(void)
{
//put code for VC2005 RTM here
cout << "RTM" << endl;
}
};

template <class VcSelectorClass<4>
{
public:
static void DoStuff(void)
{
//put code for VC2005 SP1 here
cout << "SP1" << endl;
}
};
//typedef for making things automatic without forcing you to type too
much
garbage
typedef VcSelectorClass<sizeof(&VcSelectorClass<0>::Dummy) VcSelector;

int _tmain(int argc, _TCHAR* argv[])
{
//do stuff that depends on the compiler version.
VcSelector::DoStuff();
return 0;
}
It won't look quite the same as preprocessor conditionals though.

Nope. It is slightly more verbose :-)

_CRT_ASSEMBLY_VERSION is also different between RTM and SP1, but that is
a
string and not usable with preprocessor conditionals.
_CPPLIB_VER is an integer, but I don't know if that changed or not.

Anyway, the above solution is a good way to impress your coworkers with
black magic C++ incantations. Just be sure to document why you are doing
this.

--
Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"


Jan 22 '07 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Whitney Kew | last post by:
Hi, Is there a programmatic way to get the "general" or "overall" version of a currently running instance of the Visual Studio .NET compiler? What I mean by "general" or "overall" version is, I...
7
by: SpookyET | last post by:
/FooProject /bin (release) /doc /src (only *.cs) /temp (obj files) /test (debug) /build /Visual Studio 2003 /Visual Studio 2005
4
by: simchajoy2000 | last post by:
Hi, Is it possible to programmatically detect what display settings the user has on their monitor with ASP.NET? I need to be able to resize some of the things on my webpage if the user has...
3
by: akowald | last post by:
There's another topic like this but the code posted is in VB.NET. Well I need some help detecting mouse clicks outside the form. An event handler would be great but I can work with anything. ...
1
by: mjobbe | last post by:
Hi, I'm creating an MSI for a client app using a Visual Studio Setup Project. I'm trying to detect if Internet Explorer is running on the target computer before I start the installation. How do I...
4
by: Matt Fielder | last post by:
Posting this here as MS has informed me that microsoft.public.dotnet.languages.vb.data is not a supported group, but this one is. (seems odd since it's on their server and is a sub of this group,...
3
by: =?Utf-8?B?Um9iS2lubmV5MQ==?= | last post by:
Hello, This could be REAL simple, but I cannot find any info on it anywhere after 2 hours of searching. How can I programmatically determine if the UAC is turned in Vista using C#? I need...
1
by: Bruno43 | last post by:
How could I programmatically add multiple text boxes to a WinForm, in Visual Basic 2005 Basically I want to read a table in a database and depending on how many rows there are I would like to add...
35
by: nobody | last post by:
I need to pop up a modal JS-based dialog (for some reason can't use popup window, much less so showModalDialog()), and I'd like to imitate the system popup titlebar according to user's desktop...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.