Thread: [Text Engine] - Already defined?

  1. #1
    Registered User
    Join Date
    May 2005

    [Text Engine] - Already defined?

    For the last few days, I've been throwing together some kind of text-engine for Windows/Unix.

    It's far from finished, however, when I try to compile a test build of the thing, I get the following:

    d:\C++\Vacuus_Beta\engine_int.h(13) : error C2084: function 'int ReturnRand_InRange(int,int)' already has a body
            d:\C++\Vacuus_Beta\engine_int.h(12) : see previous definition of 'ReturnRand_InRange'
    This thing has me stumped. I previously had the the ReturnRand_InRange function within the engine.h file, but moved it to engine_int.h when I started getting "already defined" errors (including engine.h in engine_movement.h).

    I done a "search in files" thing, which returned several results - the others being commented out.

    The source can be found at:

    Oh, and I'm running VC++ .NET (2002)


  2. #2
    Registered User
    Join Date
    Jan 2005
    You need to stop your header files from being included more then once. Place this at the top of each of your header files (changing the name to the name of the header)
    #ifndef ENGINE_INT_H
    #define ENGINE_INT_H
    And at the end of the header file

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    You also need to stop putting code in header files.

    That is, unless your code is
    - a template, which needs to be instantiated with whatever types at the point of use
    - an inline function which needs expanding at the point of reference
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    May 2005
    Thanks for your help, Quantum1024.

    Also, Salem, remember this is only a test version - I fully intend on cleaning up the source later on.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking problems in Visual Studio
    By h3ro in forum C++ Programming
    Replies: 5
    Last Post: 03-04-2008, 02:39 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. Variables already defined while linking.
    By xconspirisist in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2005, 05:20 AM
  4. DLL compiling question
    By Noose in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2004, 07:16 AM
  5. Header files
    By borland_man in forum C++ Programming
    Replies: 14
    Last Post: 02-22-2002, 04:30 AM