Problem with extern
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Problem with extern

  1. #1
    Join Date
    Jul 2010
    Posts
    5

    Problem with extern

    Here is my main.h
    Code:
    #ifndef main_h
    #define main_h
    
    #define WIN32_LEAN_AND_MEAN
    #include <windows.h>
    #include <mmsystem.h>
    
    #include <string>
    #include <d3d9.h> 
    #include <d3dx9.h> 
    
    #pragma comment(lib, "d3d9.lib")
    #pragma comment(lib, "d3dx9.lib")
    #pragma comment(lib, "Winmm.lib")
    
    #define SCREEN_WIDTH 1440
    #define SCREEN_HEIGHT 900
    
    #define WNDCLASSNAME L"PoweredByShezzy"
    
    #include "CApp.h"
    #include "CCamera.h"
    
    extern CApplication g_Application;
    
    
    LRESULT CALLBACK WindowEventProc(HWND,UINT,WPARAM,LPARAM);
    #endif
    When I have added the "extern CApplication g_Application;" line I am getting errors:
    Code:
    1>  cApp.cpp
    1>d:\tomek\projects\dxtest\dxtest\main.h(24): error C2146: syntax error : missing ';' before identifier 'g_Application'
    1>d:\tomek\projects\dxtest\dxtest\main.h(24): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>d:\tomek\projects\dxtest\dxtest\main.h(24): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>  cCamera.cpp
    1>d:\tomek\projects\dxtest\dxtest\main.h(24): error C2146: syntax error : missing ';' before identifier 'g_Application'
    1>d:\tomek\projects\dxtest\dxtest\main.h(24): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>d:\tomek\projects\dxtest\dxtest\main.h(24): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    What could be the problem?

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Problem with extern

    Did you include the header that defines CApplication?

    Viggy

  3. #3
    Join Date
    Jul 2010
    Posts
    5

    Re: Problem with extern

    Yes it is: #include "CApp.h".
    BTW. Thats my first day with class programming.

  4. #4
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Problem with extern

    Remember, C++ is case sensitive. In a previous post, you called the class 'cApplication'.

    Viggy

  5. #5
    Join Date
    Jul 2010
    Posts
    5

    Re: Problem with extern

    Yeah it was the problem.
    Thank you.
    I have standarized all my variables so I hope I am not gonna lose again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center