| Clearly Visual Studio hates me |
|
Forum Index - Hobbies - Computers & Technology - Clearly Visual Studio hates me |
|
Pages: 1  |
|
|
|
| Posted on 2011-08-10 10:10:21 PM |
Link | Quote |
|
So I'm trying to do a little bit of experimenting with C++ before college starts. I'm using Visual Studio 2008 and to prove that it's not my code that's causing the issue, the entirety of the project looks like this:
Code#include "stdafx.h"
#include <windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
where stdafx.h contains
Code#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
Anyway, whenever I insert the "#include <windows.h>" line, the project refuses to compile, throwing over 150 errors in "wincon.h", most of them saying something to the effect of
Code1>[path]\wincon.h(284) : error C2146: syntax error : missing ';' before identifier 'BOOL'
1>[path]\wincon.h(284) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>[path]\wincon.h(293) : error C2086: 'int WINBASEAPI' : redefinition
1> [path]\wincon.h(283) : see declaration of 'WINBASEAPI'
Note that I've reduced the path name to [path] to combat table stretching. So, does anyone know what's up here? I've tried uninstalling and reinstalling Visual Studio with no success. I feel I should also note that Dev-C++ gives me no such errors, so I think it must be a problem with Visual Studio itself. Can anyone tell me what's up?
|
|
| Posted on 2011-08-11 12:02:33 AM |
Link | Quote |
|
|
When you're creating a new project, are you selecting Console Application or Windows Application? I'm not sure what's going on in the VS2008 area, but something similar happened to me when using DirectX in VS2010.
|
|
| Posted on 2011-08-11 01:36:15 AM |
Link | Quote |
|
Looks like WINBASEAPI is undefined for some odd reason.
I don't seem to have tchar.h over here, and I can find the WINBASEAPI definitions... try putting the #include <windows.h> in stdafx.h, before the other #includes?
|
|
| Posted on 2011-08-11 10:45:13 AM |
Link | Quote |
|
Originally posted by YakovWhen you're creating a new project, are you selecting Console Application or Windows Application?
Console Application. I can't even build a Windows Application, anyway, most likely for the same reason.
Originally posted by AlcaroLooks like WINBASEAPI is undefined for some odd reason.
I don't seem to have tchar.h over here, and I can find the WINBASEAPI definitions... try putting the #include <windows.h> in stdafx.h, before the other #includes?
Doesn't seem to help, and commenting out tchar.h didn't seem to affect anything, so I don't think its inclusion matters much.
|
|
| Posted on 2011-08-11 06:29:43 PM |
Link | Quote |
|
I tried compiling this, and got an error about not finding "targetver.h". Could you post the contents of this (you can find it with right click on file name -> Open Document "targetver.h")?
If I comment out the #include of that file, it compiles, links and runs fine (meaning it exits instantly).
Another thing that might help: Post the raw compile flags. For me, it's in [project name]->Properties->C/C++->Command Line and looks like this:
Quote/Od /D "_MBCS" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP /errorReport:prompt
Telling the linker command line won't do any harm, but it doesn't seem like you're getting that far, so it won't do any good either.
|
|
| Posted on 2011-08-11 08:53:45 PM |
Link | Quote |
|
Originally posted by AlcaroCould you post the contents of this (you can find it with right click on file name -> Open Document "targetver.h")?
If I comment out the #include of that file, it compiles, links and
runs fine (meaning it exits instantly).
Sure thing:
Code#pragma once
// The following macros define the minimum required platform. The minimum required platform
// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
// your application. The macros work by enabling all features available on platform versions up to and
// including the version specified.
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Specifies that the minimum required platform is Windows Vista.
#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0.
#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE.
#endif
Originally posted by AlcaroAnother thing that might help: Post the raw compile flags. For me, it's in [project name]->Properties->C/C++->Command Line and looks like this:
Here you go:
Code/Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE"
/Gm /EHsc /RTC1 /MDd /Yu"stdafx.h" /Fp"Debug\Test4.pch" /Fo"Debug\\"
/Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP /errorReport:prompt
|
|
| Posted on 2011-08-12 01:30:27 AM |
Link | Quote |
|
I still can't reproduce anything. Not even any problems with using WINVER=Vista when compiling and running on an XP machine.
Idea 1: Disable Unicode by going into [Solution]->Character Set->Use Multi-Byte Character Set.
Idea 2: Your SDKs may be messed up. Redownload and reinstall Visual Studio.
Idea 3: My only remaining idea is to use another compiler and/or IDE. I've heard a bit about Code::Blocks, it might work better. (Note that I haven't tried it. I just use Notepad, but this is too basic for beginners.)
|
|
| Posted on 2011-08-14 10:00:08 AM |
Link | Quote |
|
Originally posted by AlcaroIdea 2: Your SDKs may be messed up. Redownload and reinstall Visual Studio.
That seemed to be the problem, though reinstalling Visual Studio didn't fix it. It seems that when you uninstall it it doesn't delete the SDKs, and when you reinstall it, it won't reinstall the SDKs if they already exist on your computer. After I manually deleted them and reinstalled, it worked like a charm. Thanks!
|
|
|
Pages: 1  |
|
|
|
|
Forum Index - Hobbies - Computers & Technology - Clearly Visual Studio hates me |