...

View Full Version : linker problems??



Shawn Curry
10-23-2002, 07:10 AM
I have 5 translation units now for my long math class. They all begin and end with:

#ifndef INTEGER_H
#define INTEGER_H

#endif

the individual files have their own symbols, but im having some problems with that statement now. Correct me if im wrong, but I thought that you use #ifndef to make sure your file is compiled once, right? For some reason, I get "LNK2001: Linker could not resolve external symbol: blah blah blah". And then goes on to list all the Whole number class functions that I had been using. Each of my translation units has an #include for everything it uses, and the only way I can compile is if I lose the #ifndef.

Anyone know what i'm doing wrong?

Oh yeah I'm using MSVC++ Intro Ed.

fivesidecube
11-05-2002, 01:23 PM
Shawn,

You should be using the #ifndef preprocessor command make sure that declarations are uncluded once! If you are using the INTEGER_H precompiler flag for all files then you will run into problems.

I can think of two area's where you use the #ifndef... The first is prevent the re-declaration of types. The second is to control the inclusion of optional source code, like debug messages.

To start with, make sure that your #ifdef XXX statements appear in header files only and that the name of the defined object is the name of header file in upper case with the '.' character replaced with a '_' character.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum