Link to home
Start Free TrialLog in
Avatar of KaranGupta
KaranGupta

asked on

Fatal Error C1189

Hi

I am getting this error

fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>

This error is not coming on my machine but it is coming when I put the code on other's machine.
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

Do both machines have the same versions of Visual Studio installed?
Avatar of KaranGupta
KaranGupta

ASKER

Yes

Same service pack levels too (VS service packs not OS)?
Are you able to do a clean install of VS on a clean machine (recently imaged) to see what happens?
What version of VS are you building with and what service pack level does it have?
Are you able to recreate the issue with a small test program?

Sorry, lots of questions I know but currently there isn't enough info to assist you in diagnosing the issue. :)
Same service pack levels too (VS service packs not OS)?
[Karan]: Yes
Are you able to do a clean install of VS on a clean machine (recently imaged) to see what happens?
[Karan]: At this point of time I can do this
What version of VS are you building with and what service pack level does it have?
[Karan]: VS 2008 with service pack 1
Are you able to recreate the issue with a small test program?
[Karan]: Yes
>> Are you able to do a clean install of VS on a clean machine (recently imaged) to see what happens?
>> [Karan]: At this point of time I can do this

Then that might be a good idea, if nothing else it'll show if this is a real issue or just isolated to that one machine

>> Are you able to recreate the issue with a small test program?
>> [Karan]: Yes

Great, can you create a small project that does this and then upload it here?: http://ee-stuff.com/
Just log in using your EE credentials.

More on ee-stuff: https://www.experts-exchange.com/questions/21906270/EE-Stuff.html

Once you've uploaded the project I can take a look and see if I can get it to build (although I only have access to VS2008 Express so I'm not sure if it'll work given your project seems to use MFC).

Hi

I am sorry I can't post code here due to sensitivity of data.  Can you help me in some other way.
>> I am sorry I can't post code here due to sensitivity of data.
Not even a small test program just to recreate the problem? I'm not requesting production code, just a test project.

>> Can you help me in some other way.
Well, not without being able to have some idea of what you're doing, no.
Hi

I have commented the code for windows.h

Now I am getting this error

fatal error C1189: #error :  Your version of the Windows SDK is earlier than 6.0. Try setting the 'WINVER' and '_WIN32_WINNT' definitions in your project to less than 0x0600.
>> Now I am getting this error
If you comment out windows.h then everything that relies on it (which is nearly all the Win32 framework) will fail to build. Unless your code uses no Win32 framework (which it must do if you see that error) this is not a viable solution.
Because when I include it I am getting an error <windows.h> is already included


>> Because when I include it I am getting an error <windows.h> is already included
I understand that but that is in one isolated place in the code. If you remove it from the "top level" then everything else that relies on it will fail to build.

You really need to prove if this is a localised issue or not by trying this on a clean machine. If it's a localised issue it's probably a configuration problem on that single machine.
SOLUTION
Avatar of itsmeandnobodyelse
itsmeandnobodyelse
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Where to add this

_WIN32_WINNT=0x0500

on every page
>> Where to add this?
I really do think this is the wrong way to go. You need to figure out why this is happening. Trying to *hack* it to work isn't a solution and it's likely to just raise other problems!

Again, have you tried this on any other machines apart from the 2 so far? There is a very good chance this is a localised problem on this one machine since it works on the other. If that is the case you are trying to fix the wrong problem. Before you can fix something you really do need to know what is actually broken.
>>>> If it's a localised issue it's probably a configuration problem on that single machine.

Yes and no. The fixed including order and the errors following if not done as required are by design. The only reason why they don't arise very often is that most developers use the wizard or a working project where the issue was solved. The errors regarding wrong SDK version is due to the fact that not all SDK functions were available in the standard configuration (where the header files used - depending on the compiler - last back to 16bit Windows and to Win95/98). But if the project uses a more difficult threading model or uses dlls which were calling Windows NT fuctionality, then the corresponding macros like _WIN32_WINNT must be set correctly to make it work. The WINVER was set by the compiler anyhow. So, if the used compiler is VC6 or younger, the WINVER couldn't be the issue.
>> The only reason why they don't arise very often is that most developers use the wizard or a working project where the issue was solved.

But the asker has already confirmed both machines are set up the same, so it should build fine on both. The fact it fails to build on one suggests that machine isn't set up as expected. This is why I suggest setting up a new machine with all the config and prerequisites that are expected. If it also builds on that then the problem is the other machine, if it doesn't it's a code issue.

Anyway, I'll leave you to this since you are more adept to Windows than I (being a prediminantely cross-platform developer).
Hi

One more observation which I want to share with you guys is when I run on machine of some other collegue then after commenting #include <windows.h> from stdafx.h it started working but in some other code it is not
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi

I changed my mode from debug to release but I now I am getting an error

Unspecified error _argc

Why is it coming
>>>> but I now I am getting an error
It would be better we would have cleared the original question which surely could be answered when you tell me

1. What is your current compiler version?

2. What is the Windows Version you currently are working on?

3. Which header file throws that #error 'Your version of the Windows SDK is earlier than 6.0. Try setting the 'WINVER' and '_WIN32_WINNT''


>>>> Unspecified error _argc

When did you get that error? At compiling or linking?

Note argc is one of the arguments of main function (counter for the number of arguments passed in argv). The underline prefix iss an internal prefix for the linker.

Can you post the full context and text of that message.