Banner
Views: 240,651,157
Time: 2013-06-20 03:29:20 AM
8 users online: Alcaro, BlackMageMario, Everest, o Hadron, MoosieGames, o ShadowPhoenix, supernova38, o Yoshi Master - Guests: 16 - Bots: 22Users: 23,085 (1,323 active)
Latest: Walfgammer
Tip: Yoshi wings take you to level C8 or 1C8. Which one you get depends on the overworld level you're in.
Clearly Visual Studio hates me
Forum Index - Hobbies - Computers & Technology - Clearly Visual Studio hates me
Pages: « 1 »
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

Code
1>[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?
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.
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?
Originally posted by Yakov
When 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 Alcaro
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?


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.
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.
Originally posted by Alcaro
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).


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 Alcaro
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:


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
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.)
Originally posted by Alcaro
Idea 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

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2013 - SMW Central
Legal Information - Link To Us


Total queries: 27

Menu