Sign in to follow this  
LewsTherin

VS 2003, I think I broke my system

Recommended Posts

LewsTherin    139
I'm trying to build a 3D game I've been working on in VS 2003 (previously built in Linux with GCC). I'm getting hundreds of bizarre errors from the standard library, which makes me think I've somehow broken VS' build environment. I also have VS 2005 installed - could that have broken 2003 somehow? Here's a sample of the errors I'm getting:
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(16) : error C2504: '_Outit' : base class undefined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(50) : see reference to class template instantiation 'Errors::std::back_insert_iterator<_Container>' being compiled
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(63) : error C2504: '_Outit' : base class undefined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(97) : see reference to class template instantiation 'Errors::std::front_insert_iterator<_Container>' being compiled
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(110) : error C2504: '_Outit' : base class undefined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(146) : see reference to class template instantiation 'Errors::std::insert_iterator<_Container>' being compiled
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(162) : error C2504: 'iterator' : base class undefined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(219) : see reference to class template instantiation 'Errors::std::istream_iterator<_Ty,_Elem,_Traits,_Diff>' being compiled
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(162) : error C2143: syntax error : missing ',' before '<'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(169) : error C2143: syntax error : missing ';' before '<'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(169) : error C2238: unexpected token(s) preceding ';'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(176) : error C2143: syntax error : missing ')' before '&'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(176) : error C2143: syntax error : missing ';' before '&'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(176) : error C2059: syntax error : ')'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(177) : error C2065: '_Istr' : undeclared identifier
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(177) : error C3861: '_Myistr': identifier not found, even with argument-dependent lookup
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(178) : error C2531: 'Errors::std::istream_iterator<_Ty,_Elem,_Traits,_Diff>::_Istr' : reference to a bit field illegal
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(178) : error C2501: 'Errors::std::istream_iterator<_Ty,_Elem,_Traits,_Diff>::_Istr' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(179) : warning C4183: '_Getval': missing return type; assumed to be a member function returning 'int'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(182) : error C2143: syntax error : missing ';' before 'const'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(243) : error C2504: '_Outit' : base class undefined
        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(281) : see reference to class template instantiation 'Errors::std::ostream_iterator<_Ty,_Elem,_Traits>' being compiled
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(247) : error C2143: syntax error : missing ';' before '<'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(247) : error C2238: unexpected token(s) preceding ';'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(249) : error C2143: syntax error : missing ')' before '&'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(249) : error C2143: syntax error : missing ';' before '&'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(249) : error C2501: 'Errors::std::ostream_iterator<_Ty,_Elem,_Traits>::_Ostr' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(249) : error C2143: syntax error : missing ';' before '*'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(249) : error C2501: 'Errors::std::ostream_iterator<_Ty,_Elem,_Traits>::_Elem' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\iterator(249) : error C2864: '_Delim' : only const static integral data members can be initialized inside a class or struct

Share this post


Link to post
Share on other sites
Mushu    1396
Unless you modified any of its includes, I highly doubt you broke anything.

Does it produce the same errors in 2005? I think you've got a mismatched brace somewhere (link). This might cause you to accidentially include something out of the global scope, causing undefined behavior (link).

Share this post


Link to post
Share on other sites
Evil Steve    2017
It's near impossible to say without seeing some source code. All I can guess is that the order of your header includes matters for some reason.

Can we see the part of your code where you include the standard headers? You could try commenting out header includes till the error goes away (Or rather, ends up in your project), that'll tell you what header is causing the problems.

Share this post


Link to post
Share on other sites
LewsTherin    139
There's a lot of code in the project. I'll post the first files to choke:

Image.h
#ifndef UTIL_IMAGE_H
#define UTIL_IMAGE_H

#include <OS/Window.h>
#include <cstring>
#include <cstdio>
#include <string>

typedef unsigned char byte;

// Errors throwable by Image
namespace Errors {

class ImageError : public std::runtime_error {
public:
ImageError(const std::string& filename);
~ImageError() throw () {}
virtual const char* what() const throw();

protected:
const std::string filename;
};

class ImageFormatError : public ImageError {
public:
ImageFormatError(const std::string& filename);
~ImageFormatError() throw () {}
virtual const char* what() const throw();
};

}

namespace Util {

class Image {
public:
/**
Supported image types
*/

enum ImageType {
IMAGE_PNG, /**< Portable Network Graphic (.png) */
IMAGE_TGA, /**< Targa (.tga) */
IMAGE_JPEG, /**< JPEG */
IMAGE_BMP, /**< Windows bitmap (.bmp) */
IMAGE_UNKNOWN,/**< Unsupported image */
IMAGE_TYPE_COUNT = IMAGE_UNKNOWN /**< Number of image types */
};

/**
Construct an image

\param filename A file to load an image from. If this is given, an image
will be loaded. If it is not specified, no image will be loaded.
*/

Image(const std::string& filename = "");
~Image();

/**
Load an image from a file

\param filename The image's filename
*/

void load(const std::string& filename);

/**
Clear the image's pixel data, and reset all attributes
*/

void clear();

/**
Get an OpenGL texture id for this image
*/

GLuint get_texture_id(const bool mipmap = true);

unsigned long get_width() const;
unsigned long get_height() const;

/**
Return the pixel data for this image
*/

const byte* const get_pixels() const;

private:
/**
Load a PNG

\param filename A PNG file
*/

void load_png(const std::string& filename);

/**
Load a TGA image, comressed or uncompressed

\param filename A TGA file
*/

void load_tga(const std::string& filename);

/**
Load a Windows bitmap image. Only uncompressed bitmaps are supported

\param filename A bitmap file
*/

void load_bmp(const std::string& filename);

/**
Image pixels
*/

byte* pixels;

/**
Type of the currently loaded image
*/

ImageType type;

/**
Which format the pixels are in
*/

unsigned int format;

/**
Width of the image
*/

unsigned long width;

/**
Height of the image
*/

unsigned long height;

/**
Bytes per pixel (AKA color depth)
*/

int bpp;

/**
OpenGL texture id
*/

GLuint id;
};

} // namespace

#endif // UTIL_IMAGE_H



Which includes OS/Window.h (look at the very bottom for more includes)
#ifndef OS_WINDOW_H
#define OS_WINDOW_H

// Needed for Windows OpenGL
#ifdef WIN32
#include <windows.h>
#endif
#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#endif
#include "glext.h"
#include <stdexcept>
#include <string>

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

namespace Errors {

class NoSuchExtensionError : public std::runtime_error {
public:
NoSuchExtensionError(const std::string& extension_name);
~NoSuchExtensionError() throw() {}
virtual const char* what() const throw();

protected:
std::string extension_name;
};

class WindowInitializationError : public std::runtime_error {
public:
WindowInitializationError(const std::string& message);
~WindowInitializationError() throw() {}
const char* what() const throw();

protected:
std::string message;
};

class WindowCloseError : public std::runtime_error {
public:
WindowCloseError(const std::string& message);
~WindowCloseError() throw() {}
const char* what() const throw();

protected:
std::string message;
};

} // namespace

namespace OS {

class EventQueue;

class Window {
public:
// Construct the window
Window(const std::string& title = "", const unsigned int width = 1024,
const unsigned int height = 768, const unsigned int depth = 32);

// Destroy the window
virtual ~Window();

// Swap window buffers
virtual void swap_buffers() const = 0;

// Call this when the window is resized by the OS,
// or to resize it manually
virtual void resize(const unsigned int width, const unsigned int height);

// Change the color depth
virtual void set_depth(const unsigned int depth);

// Get window properties
unsigned int get_width() const;
unsigned int get_height() const;
unsigned int get_depth() const;

// Set fullscreen state
virtual void set_fullscreen(const bool enable_fullscreen);

// Get the fullscreen state
bool get_fullscreen() const;

// Set the mouse mode
virtual void set_grab_mouse(const bool enabled) = 0;
virtual void set_show_mouse(const bool enabled) = 0;
bool get_grab_mouse() const;
bool get_show_mouse() const;

// Get the event queue used by this window
EventQueue* get_event_queue() const;

// Add any new events to the queue
virtual void update_event_queue() = 0;

// Load a new extension
virtual void* load_extension(const char* extension_name) const = 0;

protected:
virtual void open() = 0;
virtual void close() = 0;

// Reopen the window
virtual void reopen();

// Initialize OpenGL
void initGL();

// Which Filter To Use
GLuint filter;

unsigned int width;
unsigned int height;
unsigned int depth;

bool fullscreen;

std::string title;

// Push events to this queue
EventQueue* queue;

// Current mouse mode
bool grab_mouse;
bool show_mouse;
};

} // Namespace

#if USE_SDL
#include <OS/SDL/SDLWindow.h>
#endif

#if USE_GLX
#include <OS/GLX/GLXWindow.h>
#endif

#if USE_WIN32
#include <OS/Win32/Win32Window.h>
#endif

#endif /* OS_WINDOW_H */



Which includes OS/Win32/Win32Window.h
#ifndef OS_WIN32_WINDOW_H
#define OS_WIN32_WINDOW_H

#include <OS/Window.h>
#define WIN32_LEAN_AND_MEAN
#define DIRECTINPUT_VERSION 0x0800
#include <windows.h>
#include <d3dx8.h>
#include <dinput.h>

namespace Errors {

class Win32InitializationError : public WindowInitializationError {
public:
Win32InitializationError(DWORD code);
~Win32InitializationError() throw (){};
const char* what() const throw ();

protected:
std::string message;

};

namespace OS {

class Win32Window : public Window {
friend LRESULT CALLBACK WndProc(HWND handle, UINT msg, WPARAM wParam, LPARAM lParam);
public:
// Construct the window
Win32Window(const std::string& title = "", const int width = 1024,
const int height = 768, const int depth = 32);

// Destroy the window
~Win32Window();

// Swap window buffers
void swap_buffers() const;

// Change the color depth
void set_depth(const int depth);

// Set fullscreen state
void set_fullscreen(const bool enable_fullscreen);

// Set the mouse mode
void set_grab_mouse(const bool enabled);
void set_show_mouse(const bool enabled);

void update_event_queue();

// Load a new extension
void* load_extension(const char* extension_name) const;

protected:
void open();
void close();

HWND handle;
HDC device_context;
HGLRC hRC;
HINSTANCE hInstance;
LPDIRECTINPUTDEVICE8 g_pMouse;
LPDIRECTINPUT8 g_lpDI;
HANDLE g_hMouseEvent;
};

} // Namespace
#endif // OS_WIN32_WINDOW_H

Share this post


Link to post
Share on other sites
Deyja    920
Ha, that's actually an easy one. In OS/Win32/Win32Window.h, you never closed the namespace 'Errors'. Ironic.

Share this post


Link to post
Share on other sites
LewsTherin    139
Quote:
Original post by Deyja
Ha, that's actually an easy one. In OS/Win32/Win32Window.h, you never closed the namespace 'Errors'. Ironic.


Haha, that's pretty funny. I guess it lived up to its name!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this