Compile Error

This is a discussion on Compile Error within the C++ Programming forums, part of the General Programming Boards category; Code: #include "console.h" Console::Console() { hIn = GetStdHandle(STD_INPUT_HANDLE); hOut = GetStdHandle(STD_OUTPUT_HANDLE); scrBufferSize.X = CONSOLE_WIDTH; scrBufferSize.Y = CONSOLE_HEIGHT; SetConsoleScreenBufferSize(hOut, scrBufferSize); SetConsoleDisplayMode(hOut, ...

  1. #1
    Registered User MacNilly's Avatar
    Join Date
    Oct 2005
    Posts
    320

    Compile Error



    Code:
    #include "console.h"
    
    Console::Console()
    {
        hIn = GetStdHandle(STD_INPUT_HANDLE);
        hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    
        scrBufferSize.X = CONSOLE_WIDTH;
        scrBufferSize.Y = CONSOLE_HEIGHT;
        
        SetConsoleScreenBufferSize(hOut, scrBufferSize);
        SetConsoleDisplayMode(hOut, CONSOLE_FULLSCREEN_MODE, scrBufferSize);
    };
    I am attempting to write a constructor for Windows console class, I have #included <windows.h> but Dev-C++ says this function SetConsoleDisplayMode is undeclared, as well as the CONSOLE_FULLSCREEN_MODE. Yes, they have been defined in wincon.h also. Can someone help me understand why the compiler can't see this function and named constant?

  2. #2
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,700
    #include "console.h"
    What is this?
    To solve your problem, say I have two source files: one for main, and another for this class constructor. I must #include "console.h" in my main() source file, but #include <windows.h> in console.h:

    main.cpp:
    Code:
    #include "console.h"
    
    int main () { ... // etc.
    console.h
    Code:
    #include <windows.h>

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    you also need to define _WIN32_WINNT before windows.h because many of the console functions depend on it. I think you need to be using either W2K or XP. If you are using Win95/98 those functions may not be available on your os.
    Code:
    #define _WIN32_WINNT 0x500
    #include <windows.h>

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 06:17 PM
  4. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21