title: Getting console size after Initialize the output
body: <p>I am creating a cross platform application and for doing that I am opening header source code files of GCC/Mingw  and copied the definitions from there to my header files as and when required. The Project upto now running correctly but now struck with the error and the code is</p>
  
  <p>console.c</p>
  
  <pre><code>     #include&lt;console.h&gt;
       HANDLE write_Console
  
  
  int get_console_size(){
      if( ( write_Console = CreateFile( "CONOUT$", 
                    GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | 
                    FILE_SHARE_WRITE, 0L, OPEN_EXISTING, 
                    FILE_ATTRIBUTE_NORMAL, 0L) ) == (HANDLE) -1 
               ) {
          printf("opened");
      }
      }
  
  
  void console_settings_init(){
  
      //For writing on the console
      write_Console = GetStdHandle(STD_OUTPUT_HANDLE);
  
      //For Reading from Console
      read_Console = GetStdHandle(STD_INPUT_HANDLE);
  
      // Set up the required window size:
      SMALL_RECT windowSize = {0, 0, CONSOLE_WIDTH-1, CONSOLE_HEIGHT-1};
  
      // Change the console window size:
      SetConsoleWindowInfo(write_Console, TRUE, &amp;windowSize);
  
  
      // Create a COORD to hold the buffer size:
      COORD bufferSize = {CONSOLE_WIDTH, CONSOLE_HEIGHT};
  
      // Change the internal buffer size:
      SetConsoleScreenBufferSize(write_Console, bufferSize);
  
      recheck_console():
  }
  </code></pre>
  
  <p>*If, I don't write the function get_console_size then it is compiled very well*</p>
  
  <p>But after adding get_console_size it produces the following error with CreateFile function as __cdecl:</p>
  
  <pre><code> console.c:(.text+0x4a): undefined reference to `_CreateFile'
  </code></pre>
  
  <p>But when I tried to compile is with __declspec(dllimport) it produces the following error:</p>
  
  <pre><code> console.c:(.text+0x4a): undefined reference to `__imp__CreateFile'
  </code></pre>
  
  <p>GCC Compiling Command used:</p>
  
  <pre><code> gcc -DHAVE_CONFIG_H -I. -I..  -I../include    
       -nostdinc -Wall -fno-builtin -Wno-pragmas -Werror -MT 
        console.o -MD -MP -MF .deps/console.Tpo -c -o console.o console.c
        mv -f .deps/console.Tpo .deps/console.Po
  </code></pre>
  
  <p>After searching the Google I found that it is inbuilt function in Kernel32.dll.</p>
  
  <p>Now, I simply want to verify that console size is properly set or not?</p>
  
  <p>Can use any other method or any other things to do so?</p>
  
  <p>What are _<em>imp</em>_CreateFile and `_CreateFile functions and where they are defined?</p>
  
  <p>How can I link windows Kernel32.dll with GCC Project?</p>