[Text Engine] - Already defined?

This is a discussion on [Text Engine] - Already defined? within the Game Programming forums, part of the General Programming Boards category; For the last few days, I've been throwing together some kind of text-engine for Windows/Unix. It's far from finished, however, ...

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    41

    [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:

    Code:
    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:
    http://bur.st/~vacuus/engine/

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

    Thanks

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    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)
    Code:
    #ifndef ENGINE_INT_H
    #define ENGINE_INT_H
    And at the end of the header file
    Code:
    #endif

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,334
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    May 2005
    Posts
    41
    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, 01: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, 06:16 AM
  5. Header files
    By borland_man in forum C++ Programming
    Replies: 14
    Last Post: 02-22-2002, 03:30 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21