in VC7.1, is there a way to found out that your compiling on vista ?

thanks

yomgui

Re: [vc7.1] #ifdef vista ? by Igor

Igor
Wed Dec 05 12:42:03 PST 2007

yomgui <not@valid.com> wrote:
> in VC7.1, is there a way to found out that your compiling on vista ?

Why do you care which OS you are compiling under? Shouln'd you care
which OS your application is running under, instead?
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925



Re: [vc7.1] #ifdef vista ? by yomgui

yomgui
Wed Dec 05 13:01:43 PST 2007

Igor Tandetnik wrote:
> yomgui <not@valid.com> wrote:
>> in VC7.1, is there a way to found out that your compiling on vista ?
>
> Why do you care which OS you are compiling under? Shouln'd you care
> which OS your application is running under, instead?

I am producing a binary for xp
and a binary for vista with the same code.

I am not interested in run time solutions.

thanks

yomgui

Re: [vc7.1] #ifdef vista ? by Norbert

Norbert
Wed Dec 05 13:25:50 PST 2007


yomgui schrieb:
> Igor Tandetnik wrote:
>> yomgui <not@valid.com> wrote:
>>> in VC7.1, is there a way to found out that your compiling on vista ?
>>
>> Why do you care which OS you are compiling under? Shouln'd you care
>> which OS your application is running under, instead?
>
> I am producing a binary for xp
> and a binary for vista with the same code.
>
> I am not interested in run time solutions.

That's exactly what Igor said.
You don't care what OS you compile *under*, you care what OS you compiler *for*.
Under Windows XP, you can generate both application types for XP and Vista.
Usually you make the choice by generating some defines:

For Vista:

#define _WIN32_WINNT 0x0600
#define WINVER 0x0600

for Windows XP:

#define _WIN32_WINNT 0x0501
#define WINVER 0x0501

This enables new Vista-only functions in the platform SDK headers and disables
them for Windows XP.

You should download and install the latest platform SDK when you intend to use
Vista-specific functions.

Norbert

Re: [vc7.1] #ifdef vista ? by yomgui

yomgui
Wed Dec 05 14:06:56 PST 2007

I'd like to replace your line
> For Vista:

with
#ifdef vista


I don't want to maintain 2 source files, just one
which detect at compilation time on which platform I'm compiling.
(actually the same source file is also used for linux, osx, sgi and sun
and the different compilers provides "define" related to each platform)

so how can I differentiate vista from xp at compilation time ?

thanks

yomgui


Re: [vc7.1] #ifdef vista ? by yomgui

yomgui
Wed Dec 05 14:10:08 PST 2007

> That's exactly what Igor said.
> You don't care what OS you compile *under*, you care what OS you
> compiler *for*. Under Windows XP, you can generate both application
> types for XP and Vista. Usually you make the choice by generating some
> defines:

I have a vista machine to compile for vista and an xp machine to compile
for xp.

one of the 3rd party libraries I am using has a bug on vista that
obliges me to have a specific code on vista.

thanks

yomgui

Re: [vc7.1] #ifdef vista ? by Victor

Victor
Wed Dec 05 14:12:17 PST 2007

Igor Tandetnik wrote:
> yomgui <not@valid.com> wrote:
>> in VC7.1, is there a way to found out that your compiling on vista ?
>
> Why do you care which OS you are compiling under? Shouln'd you care
> which OS your application is running under, instead?

A common mistake of using "under" as a directional adjective. E.g.
in Russian you'd vary the grammatical case of "operating system":
instrumental for the same meaning as in English, and accusative
for the "target" or "goal" (expressed in English terms better by
means of the "for": "compile _for_ Vista").

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask



Re: [vc7.1] #ifdef vista ? by Norbert

Norbert
Wed Dec 05 14:26:34 PST 2007


yomgui schrieb:

>> That's exactly what Igor said.
>> You don't care what OS you compile *under*, you care what OS you
>> compiler *for*. Under Windows XP, you can generate both application
>> types for XP and Vista. Usually you make the choice by generating some
>> defines:
>
> I have a vista machine to compile for vista and an xp machine to compile
> for xp.

THat does not make any sense. The compiler will producer exactly the same
executable no matter if it runs on XP or vista.

> one of the 3rd party libraries I am using has a bug on vista that
> obliges me to have a specific code on vista.

So you must tell the compiler to generate the vista workaround code. You can do
this by generating an additional build configuration that adds a VISTA
preprocessor define for the vista build.

I know of no automatic discovery of the opetating system you run the compiler
on. Vista and Windows XP are treated the same in this respect.

NOrbert

Re: [vc7.1] #ifdef vista ? by Ben

Ben
Wed Dec 05 14:45:31 PST 2007


"Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
news:fj77o2$h26$1@news.datemas.de...
> Igor Tandetnik wrote:
>> yomgui <not@valid.com> wrote:
>>> in VC7.1, is there a way to found out that your compiling on vista ?
>>
>> Why do you care which OS you are compiling under? Shouln'd you care
>> which OS your application is running under, instead?
>
> A common mistake of using "under" as a directional adjective. E.g.
> in Russian you'd vary the grammatical case of "operating system":
> instrumental for the same meaning as in English, and accusative
> for the "target" or "goal" (expressed in English terms better by
> means of the "for": "compile _for_ Vista").

Yeah, but the OP used "on", not "under"... so I think Igor has it right, no
misunderstanding.

I think the OP is in the autotools mindset where you recompile the
application on the platform where you intend to run it.

Do a runtime check, or at least an install time check.

If a runtime check is too expensive (and it shouldn't be, test once when
your program starts and set a function pointer to the correct version), then
you can have two .exes and let the installer copy the appropriate one.



Re: [vc7.1] #ifdef vista ? by Jochen

Jochen
Wed Dec 05 23:24:21 PST 2007

Hi yomgui!

Replace

> #ifdef vista

with

#if WINVER >= 0x0600

then you have what you want.

Greetings
Jochen

Re: [vc7.1] #ifdef vista ? by Tim

Tim
Sat Dec 08 20:58:37 PST 2007

"Jochen Kalmbach [MVP]" <nospam-Jochen.Kalmbach@holzma.de> wrote:
>
>Replace
>
>> #ifdef vista
>
>with
>
>#if WINVER >= 0x0600
>
>then you have what you want.

Well, it will do what he NEEDS, although not what he WANTED. His original
intent, although misguided, was to detect the system on which the
compilation was occurring. In order to change WINVER, he has to change his
project properties. That is, he has to make the conscious decision "now I
wish to compile for XP", and "now I wish to compile for Vista".

This is, of course, the right way to do it.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.