5 Replies - 2202 Views - Last Post: 11 October 2012 - 01:02 AM Rate Topic: -----

#1 Polantaris  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 12
  • Joined: 02-March 12

Sudden Compile Errors with "c++locale.h"

Posted 10 October 2012 - 03:31 AM

I recently purchased a book that deals with 2D Programming with DirectX. I have some experience in terms of console programming, however I've always been bad at the graphics department. So I've been reading this book, reading code, compiling and editing code to see what I can do, etc. At Chapter 4, it introduces Inputs using XInput. This is where things went to hell. I'm not exactly sure why, but after importing the provided code, I get a massive amount of errors dealing with "c++locale.h" in my mingw folder. There's nothing wrong with this file, I've made plenty-a-program and have had no issues regarding this in the past. I really have no idea what is going on.

At first I was getting a large amount of errors regarding macros that XInput uses like "__in", "__out", and "__reserved". When looked this up, I learned that a file "sal.h" should be included if these issues arise, due to shortcuts that are used in that file. If I include that file, or just manually add the #defines for the said commands, I then run into a boatload of errors in "c++locale.h". To make sure there was nothing wrong with the file (that I can tell), I loaded and compiled several other programs I have. All compile fine.

Included below is the "input.h" file that is part of the example program (where I added the #defines), and also the list of errors I have received for the attempt at building.

input.h
#ifndef _INPUT_H                // prevent multiple definitions if this
#define _INPUT_H                // ..file is included in more than one place
#define WIN32_LEAN_AND_MEAN

#define __in        __pre __valid __pre __deref __readonly
#define __out       __ecount(1) __post __valid __refparam
#define __reserved  __pre __null

#include <windows.h>
#include <WindowsX.h>
#include <string>
#include <XInput.h>
#include "constants.h"
#include "gameError.h"

// for high-definition mouse
#ifndef HID_USAGE_PAGE_GENERIC
#define HID_USAGE_PAGE_GENERIC      ((USHORT) 0x01)
#endif
#ifndef HID_USAGE_GENERIC_MOUSE
#define HID_USAGE_GENERIC_MOUSE     ((USHORT) 0x02)
#endif
//--------------------------

namespace inputNS
{
    const int KEYS_ARRAY_LEN = 256;     // size of key arrays

    // what values for clear(), bit flag
    const UCHAR KEYS_DOWN = 1;
    const UCHAR KEYS_PRESSED = 2;
    const UCHAR MOUSE = 4;
    const UCHAR TEXT_IN = 8;
    const UCHAR KEYS_MOUSE_TEXT = KEYS_DOWN + KEYS_PRESSED + MOUSE + TEXT_IN;
}

const DWORD GAMEPAD_THUMBSTICK_DEADZONE = (DWORD)(0.20f * 0X7FFF);    // default to 20% of range as deadzone
const DWORD GAMEPAD_TRIGGER_DEADZONE = 30;                      // trigger range 0-255
const DWORD MAX_CONTROLLERS = 4;                                // Maximum number of controllers supported by XInput

// Bit corresponding to gamepad button in state.Gamepad.wButtons
const DWORD GAMEPAD_DPAD_UP        = 0x0001;
const DWORD GAMEPAD_DPAD_DOWN      = 0x0002;
const DWORD GAMEPAD_DPAD_LEFT      = 0x0004;
const DWORD GAMEPAD_DPAD_RIGHT     = 0x0008;
const DWORD GAMEPAD_START_BUTTON   = 0x0010;
const DWORD GAMEPAD_BACK_BUTTON    = 0x0020;
const DWORD GAMEPAD_LEFT_THUMB     = 0x0040;
const DWORD GAMEPAD_RIGHT_THUMB    = 0x0080;
const DWORD GAMEPAD_LEFT_SHOULDER  = 0x0100;
const DWORD GAMEPAD_RIGHT_SHOULDER = 0x0200;
const DWORD GAMEPAD_A              = 0x1000;
const DWORD GAMEPAD_B              = 0x2000;
const DWORD GAMEPAD_X              = 0x4000;
const DWORD GAMEPAD_Y              = 0x8000;

struct ControllerState
{
    XINPUT_STATE        state;
    XINPUT_VIBRATION    vibration;
    float               vibrateTimeLeft;    // mSec
    float               vibrateTimeRight;   // mSec
    bool                connected;
};

class Input
{
private:
    bool keysDown[inputNS::KEYS_ARRAY_LEN];     // true if specified key is down
    bool keysPressed[inputNS::KEYS_ARRAY_LEN];  // true if specified key was pressed
    std::string textIn;                         // user entered text
    char charIn;                                // last character entered
    bool newLine;                               // true on start of new line
    int  mouseX, mouseY;                        // mouse screen coordinates
    int  mouseRawX, mouseRawY;                  // high-definition mouse data
    RAWINPUTDEVICE Rid[1];                      // for high-definition mouse
    bool mouseCaptured;                         // true if mouse captured
    bool mouseLButton;                          // true if left mouse button down
    bool mouseMButton;                          // true if middle mouse button down
    bool mouseRButton;                          // true if right mouse button down
    bool mouseX1Button;                         // true if X1 mouse button down
    bool mouseX2Button;                         // true if X2 mouse button down
    ControllerState controllers[MAX_CONTROLLERS];    // state of controllers

public:
    // Constructor
    Input();

    // Destructor
    virtual ~Input();

    // Initialize mouse and controller input.
    // Throws GameError
    // Pre: hwnd = window handle
    //      capture = true to capture mouse.
    void initialize(HWND hwnd, bool capture);

    // Save key down state
    void keyDown(WPARAM);

    // Save key up state
    void keyUp(WPARAM);

    // Save the char just entered in textIn string
    void keyIn(WPARAM);

    // Returns true if the specified VIRTUAL KEY is down, otherwise false.
    bool isKeyDown(UCHAR vkey) const;

    // Return true if the specified VIRTUAL KEY has been pressed in the most recent frame.
    // Key presses are erased at the end of each frame.
    bool wasKeyPressed(UCHAR vkey) const;

    // Return true if any key was pressed in the most recent frame.
    // Key presses are erased at the end of each frame.
    bool anyKeyPressed() const;

    // Clear the specified key press
    void clearKeyPress(UCHAR vkey);

    // Clear specified input buffers where what is any combination of
    // KEYS_DOWN, KEYS_PRESSED, MOUSE, TEXT_IN or KEYS_MOUSE_TEXT.
    // Use OR '|' operator to combine parmeters.
    void clear(UCHAR what);

    // Clears key, mouse and text input data
    void clearAll() {clear(inputNS::KEYS_MOUSE_TEXT);}

    // Clear text input buffer
    void clearTextIn() {textIn.clear();}

    // Return text input as a string
    std::string getTextIn() {return textIn;}

    // Return last character entered
    char getCharIn()        {return charIn;}

    // Reads mouse screen position into mouseX, mouseY
    void mouseIn(LPARAM);

    // Reads raw mouse data into mouseRawX, mouseRawY
    // This routine is compatible with a high-definition mouse
    void mouseRawIn(LPARAM);

    // Save state of mouse button
    void setMouseLButton(bool B)/> { mouseLButton = b; }

    // Save state of mouse button
    void setMouseMButton(bool B)/> { mouseMButton = b; }

    // Save state of mouse button
    void setMouseRButton(bool B)/> { mouseRButton = b; }

    // Save state of mouse button
    void setMouseXButton(WPARAM wParam) {mouseX1Button = (wParam & MK_XBUTTON1) ? true:false;
                                         mouseX2Button = (wParam & MK_XBUTTON2) ? true:false;}
    // Return mouse X position
    int  getMouseX()        const { return mouseX; }

    // Return mouse Y position
    int  getMouseY()        const { return mouseY; }

    // Return raw mouse X movement. Left is <0, Right is >0
    // Compatible with high-definition mouse.
    int  getMouseRawX()     const { return mouseRawX; }

    // Return raw mouse Y movement. Up is <0, Down is >0
    // Compatible with high-definition mouse.
    int  getMouseRawY()     const { return mouseRawY; }

    // Return state of left mouse button.
    bool getMouseLButton()  const { return mouseLButton; }

    // Return state of middle mouse button.
    bool getMouseMButton()  const { return mouseMButton; }

    // Return state of right mouse button.
    bool getMouseRButton()  const { return mouseRButton; }

    // Return state of X1 mouse button.
    bool getMouseX1Button() const { return mouseX1Button; }

    // Return state of X2 mouse button.
    bool getMouseX2Button() const { return mouseX2Button; }

    // Update connection status of game controllers.
    void checkControllers();

    // Save input from connected game controllers.
    void readControllers();

    // Return state of specified game controller.
    const ControllerState* getControllerState(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return &controllers[n];
    }

    // Return state of controller n buttons.
    const WORD getGamepadButtons(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return controllers[n].state.Gamepad.wButtons;
    }

    // Return state of controller n D-pad Up
    bool getGamepadDPadUp(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return ((controllers[n].state.Gamepad.wButtons&GAMEPAD_DPAD_UP) != 0);
    }

    // Return state of controller n D-pad Down.
    bool getGamepadDPadDown(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return ((controllers[n].state.Gamepad.wButtons&GAMEPAD_DPAD_DOWN) != 0);
    }

    // Return state of controller n D-pad Left.
    bool getGamepadDPadLeft(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return ((controllers[n].state.Gamepad.wButtons&GAMEPAD_DPAD_LEFT) != 0);
    }

    // Return state of controller n D-pad Right.
    bool getGamepadDPadRight(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return bool((controllers[n].state.Gamepad.wButtons&GAMEPAD_DPAD_RIGHT) != 0);
    }

    // Return state of controller n Start button.
    bool getGamepadStart(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return bool((controllers[n].state.Gamepad.wButtons&GAMEPAD_START_BUTTON) != 0);
    }

    // Return state of controller n Back button.
    bool getGamepadBack(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return bool((controllers[n].state.Gamepad.wButtons&GAMEPAD_BACK_BUTTON) != 0);
    }

    // Return state of controller n Left Thumb button.
    bool getGamepadLeftThumb(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return bool((controllers[n].state.Gamepad.wButtons&GAMEPAD_LEFT_THUMB) != 0);
    }

    // Return state of controller n Right Thumb button.
    bool getGamepadRightThumb(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return bool((controllers[n].state.Gamepad.wButtons&GAMEPAD_RIGHT_THUMB) != 0);
    }

    // Return state of controller n Left Shoulder button.
    bool getGamepadLeftShoulder(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return bool((controllers[n].state.Gamepad.wButtons&GAMEPAD_LEFT_SHOULDER) != 0);
    }

    // Return state of controller n Right Shoulder button.
    bool getGamepadRightShoulder(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return bool((controllers[n].state.Gamepad.wButtons&GAMEPAD_RIGHT_SHOULDER) != 0);
    }

    // Return state of controller n A button.
    bool getGamepadA(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return bool((controllers[n].state.Gamepad.wButtons&GAMEPAD_A) != 0);
    }

    // Return state of controller n B button.
    bool getGamepadB(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return bool((controllers[n].state.Gamepad.wButtons&GAMEPAD_B)/> != 0);
    }

    // Return state of controller n X button.
    bool getGamepadX(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return bool((controllers[n].state.Gamepad.wButtons&GAMEPAD_X) != 0);
    }

    // Return state of controller n Y button.
    bool getGamepadY(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return bool((controllers[n].state.Gamepad.wButtons&GAMEPAD_Y) != 0);
    }

    // Return value of controller n Left Trigger.
    BYTE getGamepadLeftTrigger(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return (controllers[n].state.Gamepad.bLeftTrigger);
    }

    // Return value of controller n Right Trigger.
    BYTE getGamepadRightTrigger(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return (controllers[n].state.Gamepad.bRightTrigger);
    }

    // Return value of controller n Left Thumbstick X.
    SHORT getGamepadThumbLX(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return (controllers[n].state.Gamepad.sThumbLX);
    }

    // Return value of controller n Left Thumbstick Y.
    SHORT getGamepadThumbLY(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return (controllers[n].state.Gamepad.sThumbLY);
    }

    // Return value of controller n Right Thumbstick X.
    SHORT getGamepadThumbRX(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return (controllers[n].state.Gamepad.sThumbRX);
    }

    // Return value of controller n Right Thumbstick Y.
    SHORT getGamepadThumbRY(UINT n)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        return (controllers[n].state.Gamepad.sThumbRY);
    }

    // Vibrate controller n left motor.
    // Left is low frequency vibration.
    // speed 0=off, 65536=100 percent
    // sec is time to vibrate in seconds
    void gamePadVibrateLeft(UINT n, WORD speed, float sec)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        controllers[n].vibration.wLeftMotorSpeed = speed;
        controllers[n].vibrateTimeLeft = sec;
    }

    // Vibrate controller n right motor.
    // Right is high frequency vibration.
    // speed 0=off, 65536=100 percent
    // sec is time to vibrate in seconds
    void gamePadVibrateRight(UINT n, WORD speed, float sec)
    {
        if(n > MAX_CONTROLLERS)
            n=MAX_CONTROLLERS;
        controllers[n].vibration.wRightMotorSpeed = speed;
        controllers[n].vibrateTimeRight = sec;
    }

    // Vibrates the connected controllers for the desired time.
    void vibrateControllers(float frameTime);
};

#endif



errors
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|230|warning: '__stdcall__' attribute only applies to function types [-Wattributes]|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|230|error: '__in' was not declared in this scope|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|231|error: '__out' was not declared in this scope|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|232|error: expression list treated as compound expression in initializer [-fpermissive]|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|236|warning: '__stdcall__' attribute only applies to function types [-Wattributes]|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|236|error: '__in' was not declared in this scope|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|237|error: '__in' was not declared in this scope|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|238|error: expression list treated as compound expression in initializer [-fpermissive]|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|242|warning: '__stdcall__' attribute only applies to function types [-Wattributes]|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|242|error: '__in' was not declared in this scope|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|243|error: '__in' was not declared in this scope|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|244|error: '__out' was not declared in this scope|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|245|error: expression list treated as compound expression in initializer [-fpermissive]|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|249|error: variable or field 'XInputEnable' declared void|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|249|error: '__in' was not declared in this scope|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|254|warning: '__stdcall__' attribute only applies to function types [-Wattributes]|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|254|error: '__in' was not declared in this scope|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|255|error: '__out' was not declared in this scope|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|256|error: '__out' was not declared in this scope|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|257|error: expression list treated as compound expression in initializer [-fpermissive]|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|263|warning: '__stdcall__' attribute only applies to function types [-Wattributes]|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|263|error: '__in' was not declared in this scope|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|264|error: '__in' was not declared in this scope|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|265|error: '__out' was not declared in this scope|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|266|error: expression list treated as compound expression in initializer [-fpermissive]|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|270|warning: '__stdcall__' attribute only applies to function types [-Wattributes]|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|270|error: '__in' was not declared in this scope|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|271|error: '__reserved' was not declared in this scope|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|272|error: '__out' was not declared in this scope|
..\..\Program Files\Microsoft DirectX SDK (June 2010)\Include\XInput.h|273|error: expression list treated as compound expression in initializer [-fpermissive]|
C:\dev\Spacewar\gameError.h||In member function 'GameError& GameError::operator=(const GameError&)':|
C:\dev\Spacewar\gameError.h|43|warning: no return statement in function returning non-void [-Wreturn-type]|
C:\dev\Spacewar\input.h|81|error: 'RAWINPUTDEVICE' does not name a type|
C:\dev\Spacewar\input.h||In member function 'void Input::setMouseXButton(WPARAM)':|
C:\dev\Spacewar\input.h|160|error: 'MK_XBUTTON1' was not declared in this scope|
C:\dev\Spacewar\input.h|161|error: 'MK_XBUTTON2' was not declared in this scope|
C:\dev\Spacewar\input.cpp||In constructor 'Input::Input()':|
C:\dev\Spacewar\input.cpp|13|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
C:\dev\Spacewar\input.cpp|16|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
C:\dev\Spacewar\input.cpp|33|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
C:\dev\Spacewar\input.cpp||In member function 'void Input::initialize(HWND, bool)':|
C:\dev\Spacewar\input.cpp|60|error: 'Rid' was not declared in this scope|
C:\dev\Spacewar\input.cpp|62|error: 'RIDEV_INPUTSINK' was not declared in this scope|
C:\dev\Spacewar\input.cpp|64|error: 'RegisterRawInputDevices' was not declared in this scope|
C:\dev\Spacewar\input.cpp||In member function 'void Input::keyDown(WPARAM)':|
C:\dev\Spacewar\input.cpp|87|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
C:\dev\Spacewar\input.cpp||In member function 'void Input::keyUp(WPARAM)':|
C:\dev\Spacewar\input.cpp|102|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
C:\dev\Spacewar\input.cpp||In member function 'bool Input::anyKeyPressed() const':|
C:\dev\Spacewar\input.cpp|163|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
C:\dev\Spacewar\input.cpp||In member function 'void Input::clear(UCHAR)':|
C:\dev\Spacewar\input.cpp|186|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
C:\dev\Spacewar\input.cpp|191|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
C:\dev\Spacewar\input.cpp||In member function 'void Input::mouseRawIn(LPARAM)':|
C:\dev\Spacewar\input.cpp|223|error: 'HRAWINPUT' was not declared in this scope|
C:\dev\Spacewar\input.cpp|223|error: 'RID_INPUT' was not declared in this scope|
C:\dev\Spacewar\input.cpp|224|error: 'RAWINPUTHEADER' was not declared in this scope|
C:\dev\Spacewar\input.cpp|224|error: 'GetRawInputData' was not declared in this scope|
C:\dev\Spacewar\input.cpp|226|error: 'RAWINPUT' was not declared in this scope|
C:\dev\Spacewar\input.cpp|226|error: 'raw' was not declared in this scope|
C:\dev\Spacewar\input.cpp|226|error: expected primary-expression before ')' token|
C:\dev\Spacewar\input.cpp|226|error: expected ';' before 'lpb'|
C:\dev\Spacewar\input.cpp|228|error: 'RIM_TYPEMOUSE' was not declared in this scope|
C:\dev\Spacewar\input.cpp||In member function 'void Input::checkControllers()':|
C:\dev\Spacewar\input.cpp|243|error: 'XInputGetState' cannot be used as a function|
C:\dev\Spacewar\input.cpp||In member function 'void Input::readControllers()':|
C:\dev\Spacewar\input.cpp|261|error: 'XInputGetState' cannot be used as a function|
C:\dev\Spacewar\input.cpp||In member function 'void Input::vibrateControllers(float)':|
C:\dev\Spacewar\input.cpp|273|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
C:\dev\Spacewar\input.cpp|289|error: 'XInputSetState' cannot be used as a function|
||=== Build finished: 42 errors, 16 warnings ===|



I am using Code::Blocks for my IDE and MinGW for my compiler. The book was written for Visual Studio C++. Is there potentially an issue with XInput because I used a different compiler?

I've looked up this issue for over an hour and can find no one who has a similar issue. Any help would be great, I'm finally starting to understand how to do my own rendering and this is a terrible wall to hit.

Is This A Good Question/Topic? 0
  • +

Replies To: Sudden Compile Errors with "c++locale.h"

#2 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3576
  • View blog
  • Posts: 11,123
  • Joined: 05-May 12

Re: Sudden Compile Errors with "c++locale.h"

Posted 10 October 2012 - 04:16 AM

My understanding is that DirectX SDK requires the use of Visual Studio at your compiler toolset, but I could be mistaken.

Anyway, as a stopgap, I would try changing the #include order, but I highly doubt it will help:
#include <windows.h>
#include <WindowsX.h>
#include <XInput.h>
#include <string>



or

#include <windows.h>
#include <WindowsX.h>
#include <sal.h>
#include <XInput.h>
#include <string>



or

#include <windows.h>
#include <WindowsX.h>
#define __in        __pre __valid __pre __deref __readonly
#define __out       __ecount(1) __post __valid __refparam
#define __reserved  __pre __null
#include <XInput.h>
#include <string>


Was This Post Helpful? 1
  • +
  • -

#3 Polantaris  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 12
  • Joined: 02-March 12

Re: Sudden Compile Errors with "c++locale.h"

Posted 10 October 2012 - 05:15 PM

View PostSkydiver, on 10 October 2012 - 04:16 AM, said:

My understanding is that DirectX SDK requires the use of Visual Studio at your compiler toolset, but I could be mistaken.

Anyway, as a stopgap, I would try changing the #include order, but I highly doubt it will help:
#include <windows.h>
#include <WindowsX.h>
#include <XInput.h>
#include <string>



or

#include <windows.h>
#include <WindowsX.h>
#include <sal.h>
#include <XInput.h>
#include <string>



or

#include <windows.h>
#include <WindowsX.h>
#define __in        __pre __valid __pre __deref __readonly
#define __out       __ecount(1) __post __valid __refparam
#define __reserved  __pre __null
#include <XInput.h>
#include <string>



It actually did help slightly, but now I get all kinds of compile errors inside XInput.h. Later on today I'll try doing this in VSC++, I have it installed somewhere. I'll post on the results of that.
Was This Post Helpful? 0
  • +
  • -

#4 Polantaris  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 12
  • Joined: 02-March 12

Re: Sudden Compile Errors with "c++locale.h"

Posted 10 October 2012 - 11:19 PM

Alright, so I installed Visual Studio C++ Express 2012, and ran the code as it was prior to any editing. Compiles and runs completely fine. I guess the MinGW compiler doesn't like XInput.

I know it's not DirectX itself, because projects prior to this one, as well as a few terrible attempts on my own/with online tutorials ran perfectly fine. It seems to be XInput that is the culprit. I can always do Input myself at a later date, that's not so hard, but I don't really want to completely edit every single example that is given in this book, so it's better to just use VSC++ for now until I am finished and have a better grasp at what I am doing and am able to make my own projects successfully. Who knows...maybe VSC++ will grow on me.

Anyway, thanks for the help regardless, I appreciate your quick reply in the matter.
Was This Post Helpful? 0
  • +
  • -

#5 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3576
  • View blog
  • Posts: 11,123
  • Joined: 05-May 12

Re: Sudden Compile Errors with "c++locale.h"

Posted 10 October 2012 - 11:35 PM

I believe that you can configure Code::Blocks to use the MSVC compiler (or the Intel compiler, or another version of GCC, etc.), but still use the Code::Blocks UI. I haven't tried it yet, though.
Was This Post Helpful? 1
  • +
  • -

#6 Polantaris  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 12
  • Joined: 02-March 12

Re: Sudden Compile Errors with "c++locale.h"

Posted 11 October 2012 - 01:02 AM

View PostSkydiver, on 10 October 2012 - 11:35 PM, said:

I believe that you can configure Code::Blocks to use the MSVC compiler (or the Intel compiler, or another version of GCC, etc.), but still use the Code::Blocks UI. I haven't tried it yet, though.


You can do that, I remember seeing the option; however it would be easier to just use VC++ anyway because all the examples are built using it, with the project files and everything so I can simply extract the examples into a folder and get right to screwing around with the code without any copy-paste or file inclusions or anything like that. It's just simpler this way. I appreciate the thought though. Thanks a lot for your help.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1