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

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Dannnyst

Thread Starter
Joined
Sep 23, 2003
Messages
1
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>
#endif

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
declaration
#endif
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.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Staff online

Top