Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8418


Ignore:
Timestamp:
May 8, 2011, 6:53:39 PM (14 years ago)
Author:
rgrieder
Message:

Added preprocessor macro UNIQUE_NUMBER which will return a new integer number every time is invoked if such a mechanism is available.
On GCC < 4.3, it will be defined as LINE. Newer GCC and MSVC support COUNTER, which is then used.
Also replaced uses of LINE with UNIQUE_NUMBER if appropriate.

Location:
code/trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/OrxonoxConfig.h.in

    r8409 r8418  
    109109#endif
    110110
     111#ifndef __UNIQUE_NUMBER__
     112#  if defined(ORXONOX_COMPILER_GCC) && ORXONOX_COMP_VER >= 430
     113#    define __UNIQUE_NUMBER__ __COUNTER__
     114#  elif defined(ORXONOX_COMPILER_MSVC)
     115#    define __UNIQUE_NUMBER__ __COUNTER__
     116#  else
     117#    define __UNIQUE_NUMBER__ __LINE__
     118#  endif
     119#endif
    111120
    112121/*---------------------------------
  • code/trunk/src/libraries/core/Game.h

    r7401 r8418  
    5959*/
    6060#define DeclareGameState(className, stateName, bIgnoreTickTime, bGraphicsMode) \
    61     static bool BOOST_PP_CAT(bGameStateDummy_##className, __LINE__) = orxonox::Game::declareGameState<className>(#className, stateName, bIgnoreTickTime, bGraphicsMode)
     61    static bool BOOST_PP_CAT(bGameStateDummy_##className, __UNIQUE_NUMBER__) = orxonox::Game::declareGameState<className>(#className, stateName, bIgnoreTickTime, bGraphicsMode)
    6262// tolua_begin
    6363namespace orxonox
  • code/trunk/src/libraries/core/ToluaInterface.h

    r7401 r8418  
    4242// Macro for declaring a tolua interface of a library/module
    4343#define DeclareToluaInterface(libraryName) \
    44     static bool BOOST_PP_CAT(bDummy##libraryName, __LINE__) = orxonox::LuaState::addToluaInterface(&tolua_##libraryName##_open, #libraryName); \
    45     static Loki::ScopeGuardImpl1<bool (*)(const std::string&), std::string> BOOST_PP_CAT(dummy##libraryName, __LINE__)(&orxonox::LuaState::removeToluaInterface, #libraryName)
     44    static bool BOOST_PP_CAT(bDummy##libraryName, __UNIQUE_NUMBER__) = orxonox::LuaState::addToluaInterface(&tolua_##libraryName##_open, #libraryName); \
     45    static Loki::ScopeGuardImpl1<bool (*)(const std::string&), std::string> BOOST_PP_CAT(dummy##libraryName, __UNIQUE_NUMBER__)(&orxonox::LuaState::removeToluaInterface, #libraryName)
    4646
    4747#endif /* _ToluaInterface_H__ */
  • code/trunk/src/libraries/core/command/ConsoleCommand.h

    r8079 r8418  
    269269/// Internal macro
    270270#define SetConsoleCommandGeneric(group, name, functor) \
    271     static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor)))
     271    static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor)))
    272272
    273273
     
    304304/// Internal macro
    305305#define DeclareConsoleCommandGeneric(group, name, functor) \
    306     static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor), false))
     306    static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor), false))
    307307
    308308
  • code/trunk/src/libraries/network/NetworkFunction.h

    r7495 r8418  
    255255
    256256#define registerStaticNetworkFunction( functionPointer ) \
    257   static void* BOOST_PP_CAT( NETWORK_FUNCTION_, __LINE__ ) = registerStaticNetworkFunctionFct( functionPointer, #functionPointer );
     257  static void* BOOST_PP_CAT( NETWORK_FUNCTION_, __UNIQUE_NUMBER__ ) = registerStaticNetworkFunctionFct( functionPointer, #functionPointer );
    258258#define registerMemberNetworkFunction( class, function ) \
    259   static void* BOOST_PP_CAT( NETWORK_FUNCTION_##class, __LINE__ ) = registerMemberNetworkFunctionFct<class>( &class::function, #class "_" #function);
     259  static void* BOOST_PP_CAT( NETWORK_FUNCTION_##class, __UNIQUE_NUMBER__ ) = registerMemberNetworkFunctionFct<class>( &class::function, #class "_" #function);
    260260  // call it with functionPointer, clientID, args
    261261#define callStaticNetworkFunction( functionPointer, ...) \
Note: See TracChangeset for help on using the changeset viewer.