Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Oct 2002
    Location
    middle of nowhere
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    linker problems??

    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.

  • #2
    New Coder
    Join Date
    Sep 2002
    Location
    Up North (UK)
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

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