1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

C++ #ifndef doesn't seem to be working

Discussion in 'Software Development' started by Dannnyst, Sep 23, 2003.

Thread Status:
Not open for further replies.
  1. Dannnyst

    Dannnyst Thread Starter

    Sep 23, 2003
    For our example say I have a class called bob. Bob needs to have several windows headers included to do some stuff with sockets. I have got the bob.cpp and bob.h files to function but am running into a problem.
    I now have to insert bob into a new program so I need to include bob.h in a new class. When I do that, I get hundreds of redefinition errors in the windows included files. So I figured I could add the following in bob.h

    #ifndef BOB_H
    #define BOB_H
    #include <file>

    So theoretically, the file that is being included twice will only include the first time bob.h is compiled. However this is not working. I cannot include bob.h in my other class so I cannot go anywhere. I have tried #pragma once as well.

    I also noticed while looking at the file that is redefining things and noticed that every definition in that file is encased with #ifndef SOMETHING
    #define SOMETHING
    but those don't seem to be working either. Anybody know what is going on here?

    I am developing with Visual Studio .net 2003 if that matters.
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/166902

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice