Thread: Help? Hopefully not a silly question. Regarding global declarations

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    I am me, who else?
    Join Date
    Oct 2002
    Posts
    250

    Help? Hopefully not a silly question. Regarding global declarations

    Perhaps this just isn't possible but I was making a program which needs a global access to a database resource. Every file includes my "global.h" file, however when I try to declare it as an extern it fails.

    Note: dbaccess is the name of the class as well.

    snippet of globals.h


    #include "dbaccess.h"
    ...

    extern dbaccess theDB;

    then it gives me 2 errors:

    error C2146: syntax error : missing ';' before identifier 'theDB'
    error C2501: 'theDB' : missing storage-class or type specifiers

    the second one should follow the first since it has no idea what theDB is apparently.

    globals.h is included by dbaccess.h, and I have guards against circular inclusion.

    I could do this in other ways I know, but it would be easier to have it global for my purposes, perhaps a bit faster as well. Any ideas / help?
    Last edited by dpro; 07-15-2005 at 05:29 PM. Reason: Changing title to be more helpful

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. noob silly pointer? question
    By darin722 in forum C++ Programming
    Replies: 2
    Last Post: 06-13-2009, 06:58 AM
  2. Global classes and a typedef question!
    By Akkernight in forum C++ Programming
    Replies: 3
    Last Post: 04-11-2009, 01:57 PM
  3. basic question about global variables
    By radeberger in forum C++ Programming
    Replies: 0
    Last Post: 04-06-2009, 12:54 AM
  4. I need help to compile this code...
    By wise_ron in forum C Programming
    Replies: 17
    Last Post: 05-07-2006, 12:22 PM
  5. defining and using a global class
    By cjschw in forum C++ Programming
    Replies: 4
    Last Post: 03-05-2004, 09:51 PM