Sign in to follow this  

Lots of Macros, can someone explain what these do?

This topic is 4380 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Whole bunch of macro's ment for repeating code
///////////////////////////////////////////////////////////////////////////////
// 
// MacroRepeat
// 
// This header provides macros for repeating code.
// 
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2004 Robert Geiman.
//
// Permission to copy, modify, and use this code for personal and commercial
// software is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without any expressed or implied warranty.
//
// Any comments or questions can be sent to: rgeiman@buckeye-express.com
//
///////////////////////////////////////////////////////////////////////////////

#ifndef MACRO_REPEAT_H
#define MACRO_REPEAT_H


///////////////////////////////////////////////////////////////////////////////
// The MACRO_EMPTY_SEPERATOR should be left empty, but Visual C++ 6.0 chokes on
// passing empty defines to macros, so to get around deficiency we define this
// macro as an empty comment section (/**/).  Note that this is NOT valid with
// a standard compliant compiler 
///////////////////////////////////////////////////////////////////////////////
#define MACRO_EMPTY_SEPERATOR /##**/
#define MACRO_COMMA_SEPERATOR ,
#define MACRO_SEMICOLAN_SEPERATOR ;
#define MACRO_BEGIN_PAREN_SEPERATOR (
#define MACRO_END_PAREN_SEPERATOR )


#define MACRO_EMPTY_MACRO(num)
#define MACRO_TEMPLATE_PARAMETER(num) typename A##num
#define MACRO_TEMPLATE_ARGUMENT(num) A##num
#define MACRO_FUNCTION_PARAMETER(num) A##num a##num
#define MACRO_FUNCTION_ARGUMENT(num) a##num


#define MACRO_REPEAT_0(begin_seperator, seperator, macro, end_seperator) 
#define MACRO_REPEAT_1(begin_seperator, seperator, macro, end_seperator) begin_seperator macro(0) end_seperator
#define MACRO_REPEAT_2(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_1(begin_seperator, seperator, macro, end_seperator) seperator macro(1) end_seperator
#define MACRO_REPEAT_3(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_2(begin_seperator, seperator, macro, end_seperator) seperator macro(2) end_seperator
#define MACRO_REPEAT_4(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_3(begin_seperator, seperator, macro, end_seperator) seperator macro(3) end_seperator
#define MACRO_REPEAT_5(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_4(begin_seperator, seperator, macro, end_seperator) seperator macro(4) end_seperator
#define MACRO_REPEAT_6(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_5(begin_seperator, seperator, macro, end_seperator) seperator macro(5) end_seperator
#define MACRO_REPEAT_7(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_6(begin_seperator, seperator, macro, end_seperator) seperator macro(6) end_seperator
#define MACRO_REPEAT_8(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_7(begin_seperator, seperator, macro, end_seperator) seperator macro(7) end_seperator
#define MACRO_REPEAT_9(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_8(begin_seperator, seperator, macro, end_seperator) seperator macro(8) end_seperator
#define MACRO_REPEAT_10(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_9(begin_seperator, seperator, macro, end_seperator) seperator macro(9) end_seperator
#define MACRO_REPEAT_11(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_10(begin_seperator, seperator, macro, end_seperator) seperator macro(10) end_seperator
#define MACRO_REPEAT_12(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_11(begin_seperator, seperator, macro, end_seperator) seperator macro(11) end_seperator
#define MACRO_REPEAT_13(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_12(begin_seperator, seperator, macro, end_seperator) seperator macro(12) end_seperator
#define MACRO_REPEAT_14(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_13(begin_seperator, seperator, macro, end_seperator) seperator macro(13) end_seperator
#define MACRO_REPEAT_15(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_14(begin_seperator, seperator, macro, end_seperator) seperator macro(14) end_seperator
#define MACRO_REPEAT_16(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_15(begin_seperator, seperator, macro, end_seperator) seperator macro(15) end_seperator
#define MACRO_REPEAT_17(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_16(begin_seperator, seperator, macro, end_seperator) seperator macro(16) end_seperator
#define MACRO_REPEAT_18(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_17(begin_seperator, seperator, macro, end_seperator) seperator macro(17) end_seperator
#define MACRO_REPEAT_19(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_18(begin_seperator, seperator, macro, end_seperator) seperator macro(18) end_seperator
#define MACRO_REPEAT_20(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_19(begin_seperator, seperator, macro, end_seperator) seperator macro(19) end_seperator
#define MACRO_REPEAT_21(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_20(begin_seperator, seperator, macro, end_seperator) seperator macro(20) end_seperator
#define MACRO_REPEAT_22(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_21(begin_seperator, seperator, macro, end_seperator) seperator macro(21) end_seperator
#define MACRO_REPEAT_23(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_22(begin_seperator, seperator, macro, end_seperator) seperator macro(22) end_seperator
#define MACRO_REPEAT_24(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_23(begin_seperator, seperator, macro, end_seperator) seperator macro(23) end_seperator
#define MACRO_REPEAT_25(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_24(begin_seperator, seperator, macro, end_seperator) seperator macro(24) end_seperator
#define MACRO_REPEAT_26(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_25(begin_seperator, seperator, macro, end_seperator) seperator macro(25) end_seperator
#define MACRO_REPEAT_27(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_26(begin_seperator, seperator, macro, end_seperator) seperator macro(26) end_seperator
#define MACRO_REPEAT_28(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_27(begin_seperator, seperator, macro, end_seperator) seperator macro(27) end_seperator
#define MACRO_REPEAT_29(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_28(begin_seperator, seperator, macro, end_seperator) seperator macro(28) end_seperator
#define MACRO_REPEAT_30(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_29(begin_seperator, seperator, macro, end_seperator) seperator macro(29) end_seperator
#define MACRO_REPEAT_31(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_30(begin_seperator, seperator, macro, end_seperator) seperator macro(30) end_seperator
#define MACRO_REPEAT_32(begin_seperator, seperator, macro, end_seperator) MACRO_REPEAT_31(begin_seperator, seperator, macro, end_seperator) seperator macro(31) end_seperator


#define MACRO_LIST(num, macro) MACRO_REPEAT_##num(MACRO_EMPTY_SEPERATOR, MACRO_COMMA_SEPERATOR, macro, MACRO_EMPTY_SEPERATOR)
#define MACRO_LIST_APPEND(num, macro) MACRO_REPEAT_##num(MACRO_COMMA_SEPERATOR, MACRO_COMMA_SEPERATOR, macro, MACRO_EMPTY_SEPERATOR)
#define MACRO_LIST_PREPEND(num, macro) MACRO_REPEAT_##num(MACRO_EMPTY_SEPERATOR, MACRO_COMMA_SEPERATOR, macro, MACRO_COMMA_SEPERATOR)
#define MACRO_BEGIN_PAREN(num, macro) MACRO_REPEAT_##num(MACRO_BEGIN_PAREN_SEPERATOR, MACRO_EMPTY_SEPERATOR, macro, MACRO_EMPTY_SEPERATOR)
#define MACRO_END_PAREN(num, macro) MACRO_REPEAT_##num(MACRO_END_PAREN_SEPERATOR, MACRO_EMPTY_SEPERATOR, macro, MACRO_EMPTY_SEPERATOR)
#define MACRO_REPEAT(num, macro) MACRO_REPEAT_##num(MACRO_EMPTY_SEPERATOR, MACRO_EMPTY_SEPERATOR, macro, MACRO_EMPTY_SEPERATOR)



#endif

And here is how they're implemented
#define OBJECT_FACTORY(num)                                                                                 
   template<typename BaseClassType MACRO_LIST_APPEND(num, MACRO_TEMPLATE_PARAMETER), typename UniqueIdType> 
   class ObjectFactory##num                                                                                 
   {                                                                                                        
   protected:                                                                                               
      class CreateObjectBase                                                                                
      {                                                                                                     
      public:                                                                                               
         virtual ~CreateObjectBase() {}                                                                     
         virtual BaseClassType *operator()(MACRO_LIST(num, MACRO_FUNCTION_PARAMETER)) = 0;                  
      };                                                                                                    
                                                                                                            
      template<typename ClassType>                                                                          
      class CreateObject : public CreateObjectBase                                                          
      {                                                                                                     
      public:                                                                                               
         BaseClassType *operator()(MACRO_LIST(num, MACRO_FUNCTION_PARAMETER))                               
         {                                                                                                  
			return new ClassType MACRO_BEGIN_PAREN(num, MACRO_EMPTY_MACRO) MACRO_LIST(num, MACRO_FUNCTION_ARGUMENT) MACRO_END_PAREN(num, MACRO_EMPTY_MACRO);
         }                                                                                                  
      };                                                                                                    
                                                                                                            
   public:                                                                                                  
      typedef typename std::map<UniqueIdType, CreateObjectBase*>::const_iterator ConstIterator;             
      typedef typename std::map<UniqueIdType, CreateObjectBase*>::iterator Iterator;                        
                                                                                                            
      ~ObjectFactory##num()                                                                                 
      {                                                                                                     
         Iterator iter = m_object_creator.begin();                                                          
                                                                                                            
         while (iter != m_object_creator.end())                                                             
         {                                                                                                  
            delete (*iter).second;                                                                          
            ++iter;                                                                                         
         }                                                                                                  
      }                                                                                                     
                                                                                                            
      template<typename ClassType>                                                                          
      bool Register(UniqueIdType unique_id, Type2Type<ClassType>)                                           
      {                                                                                                     
         if (m_object_creator.find(unique_id) != m_object_creator.end())                                    
            return false;                                                                                   
                                                                                                            
         m_object_creator[unique_id] = new CreateObject<ClassType>;                                         
                                                                                                            
         return true;                                                                                       
      }                                                                                                     
                                                                                                            
      bool Unregister(UniqueIdType unique_id)                                                               
      {                                                                                                     
         Iterator iter = m_object_creator.find(unique_id);                                                  
                                                                                                            
         if (iter != m_object_creator.end())                                                                
         {                                                                                                  
            delete (*iter).second;                                                                          
            m_object_creator.erase(iter);                                                                   
                                                                                                            
            return true;                                                                                    
         }                                                                                                  
                                                                                                            
         return false;                                                                                      
      }                                                                                                     
                                                                                                            
      BaseClassType *Create(UniqueIdType unique_id MACRO_LIST_APPEND(num, MACRO_FUNCTION_PARAMETER))        
      {                                                                                                     
         Iterator iter = m_object_creator.find(unique_id);                                                  
                                                                                                            
         if (iter == m_object_creator.end())                                                                
            return NULL;                                                                                    
                                                                                                            
         return ((*iter).second)->operator()(MACRO_LIST(num, MACRO_FUNCTION_ARGUMENT));                     
      }                                                                                                     
                                                                                                            
      ConstIterator GetBegin() const                                                                        
      {                                                                                                     
         return m_object_creator.begin();                                                                   
      }                                                                                                     
                                                                                                            
      Iterator GetBegin()                                                                                   
      {                                                                                                     
         return m_object_creator.begin();                                                                   
      }                                                                                                     
                                                                                                            
      ConstIterator GetEnd() const                                                                          
      {                                                                                                     
         return m_object_creator.end();                                                                     
      }                                                                                                     
                                                                                                            
      Iterator GetEnd()                                                                                     
      {                                                                                                     
         return m_object_creator.end();                                                                     
      }                                                                                                     
                                                                                                            
   protected:                                                                                               
      std::map<UniqueIdType, CreateObjectBase*> m_object_creator;                                           
   };                                                                                                       

MACRO_REPEAT(16, OBJECT_FACTORY)
#undef OBJECT_FACTORY

#endif

Can someone like, cut lines and snippets out of the implementation and write out longhand what you would put instead of the macro? I'm very unfamiliar with macro's and exactly how to declare them and how to use them n stuff, thanks.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I just want to say thats some of the ugliest macroing Ive seen - good luck on deciphering it. Damn you Robert Geiman! You could always email this guy and ask him, seeing how all the macros seem to be undocumented in code. ALl I can tell you is that they apparently repeat something.

Share this post


Link to post
Share on other sites
The macros are in fact an unrolled recursive definition. It says that, to repeat "FOO" X times,
- if X=1 then you write "FOO"
- otherwise, you repeat "FOO" (X-1) times, then you write "FOO"

With some additional information (like repeating slightly different things each time by writing FOO(X) instead of FOO, which assumes FOO is a macro), and separators.

In the end, it uses ## to transform a numeric argument into a hardcoded macro name corresponding with a given amount of repetitions. This results in:

MACRO_REPEAT(num,macro)

Being evaluated to:

macro(num-1) macro(num-2) ... macro(0)

Which in turn is evaluated into whatever macro becomes. This is truly ugly, by the way.

Share this post


Link to post
Share on other sites
Quote:
Original post by Shamino
Can someone like, cut lines and snippets out of the implementation and write out longhand what you would put instead of the macro? I'm very unfamiliar with macro's and exactly how to declare them and how to use them n stuff, thanks.
Most compilers can do this for you. Check your compiler's options, there should be one for invoking the preprocessor separately.
The output will probably be huge and generally unmaintainable though, so you probably want to keep the macros around and just use the preprocessor output for debugging purposes.

Share this post


Link to post
Share on other sites
He's pretty much trying to repeat a macro (that takes a number as an argument) some number of times, and expanding them in increasing order (not decreasing)

For example:

#define MY_NUM(n) n
MACRO_REPEAT(MY_NUM, 5)

Will result in something like

"MY_NUM(0) MY_NUM(1) ... MY_NUM(4)"

which then translates into

"0 1 ... 4"

No, he goes the extra step and adds seperators and stuff into that, so that he can generate parameter lists. Notice the "begin_seperator, seperator, macro, end_seperator" stuff? That's just dictates what needs to go between the generated macros. For example, if I did the following

MACRO_LIST(MY_NUM, 5)

it'll translate into "0, 1, 2, 3, 4", since the macro uses no begin and end seperators, but just shoves a comma between the 'terms' I guess you could say.

The other macros use variations of the repeat macro to constructed lists and nested lists, though they look like they need to be used in conjunction with one another.

Blegh. That's real nasty. I have no real problem with macros when used "correctly", but that's just plain old crazy.

Edit:

Oh, and as far as the class is concerned, he's just trying to make a bunch of factories for some object type (which gets registered at some point by the factory itself). I guess he ended up having to write a lot of duplicate factories that look "almost" the same for similar objects (maybe?), and got tired of it. His final goal you can see at the bottom when he does this:

"MACRO_REPEAT(16, OBJECT_FACTORY)"

He wants to make 16 factories, and wants to be able to quickly change that number whenever he feels frisky.

*shrugs*

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
"MACRO_REPEAT(16, OBJECT_FACTORY)"

He wants to make 16 factories, and wants to be able to quickly change that number whenever he feels frisky.

*shrugs*


Actually that cleared that up alot..

Share this post


Link to post
Share on other sites
Quote:
Original post by Shamino
Question though, why does he need 16 factories?
To forward a variable number of parameters to the templated class's constructor.
Yes, it's an ugly hack. But it's the best solution the language provides to the forwarding problem.

Take a look at boost::preprocessor for further details, it's basically just an advanced version of the code above but at least it's decently documented.

Share this post


Link to post
Share on other sites
So, since the template class has 16 arguements, normally he'd have to write 16 template classes to pass every single thing he needs to the one template class...

So he made a macro, nifty...

And I wouldn't call it a hack, I'd call it a nice solution.

Is this honestly an efficient way to create new instances of objects during runtime?

Share this post


Link to post
Share on other sites
And here it is, directly from the man himself, Robert Geiman.

Quote:

Attached is a text file that basically shows the output. Basically, the macro is creating 16 different versions of the same class, with each version containing an extra template parameter. These parameters are for constructor parameters you may want to pass when creating instances of your class.

My text file only includes the first 3 versions, all seperated by a ////////////// line, so you can easily compare the different versions of the class. Even though I've only included the first 3 class outputs, you can look at the differences between them and easily create the other 12 versions.

The reason for the macro's was so that you don't HAVE to create all 15 versions... and then make changes to ALL 15 if you find a bug in the class, etc.

Hope this helps!

Rob Geiman



template<typename BaseClassType, typename ClassType> BaseClassType CreateObject()
{
return new ClassType;
}

template<typename BaseClassType, typename UniqueIdType>
class ObjectFactory<BaseClassType(), UniqueIdType>
{
private:
typedef BaseClassType(*CreateObjectFunc)();

public:
typedef typename std::map<UniqueIdType, CreateObjectFunc>::const_iterator ConstIterator;
typedef typename std::map<UniqueIdType, CreateObjectFunc>::iterator Iterator;

template<typename ClassType>
bool Register(UniqueIdType unique_id)
{
if (m_object_creator.find(unique_id) != m_object_creator.end())
return false; m_object_creator[unique_id] = &CreateObject<BaseClassType , ClassType>;

return true;
}

bool Unregister(UniqueIdType unique_id)
{
return (m_object_creator.erase(unique_id) == 1);
}

BaseClassType Create(UniqueIdType unique_id )
{
Iterator iter = m_object_creator.find(unique_id);

if (iter == m_object_creator.end())
return 0;

return ((*iter).second)();
}

ConstIterator GetBegin() const
{
return m_object_creator.begin();
}

Iterator GetBegin()
{
return m_object_creator.begin();
}

ConstIterator GetEnd() const
{
return m_object_creator.end();
}

Iterator GetEnd()
{
return m_object_creator.end();
}

protected:
std::map<UniqueIdType, CreateObjectFunc> m_object_creator;
};

///////////////////////////////////////////////////////////////////////////////

template<typename BaseClassType, typename A0, typename ClassType> BaseClassType CreateObject(A0 a0)
{
return new ClassType(a0);
}

template<typename BaseClassType, typename A0, typename UniqueIdType>
class ObjectFactory<BaseClassType(A0), UniqueIdType>
{
private:
typedef BaseClassType(*CreateObjectFunc)(A0 a0);

public:
typedef typename std::map<UniqueIdType, CreateObjectFunc>::const_iterator ConstIterator;
typedef typename std::map<UniqueIdType, CreateObjectFunc>::iterator Iterator;

template<typename ClassType>
bool Register(UniqueIdType unique_id)
{
if (m_object_creator.find(unique_id) != m_object_creator.end())
return false;

m_object_creator[unique_id] = &CreateObject<BaseClassType, A0, ClassType>;

return true;
}

bool Unregister(UniqueIdType unique_id)
{
return (m_object_creator.erase(unique_id) == 1);
}

BaseClassType Create(UniqueIdType unique_id, A0 a0)
{
Iterator iter = m_object_creator.find(unique_id);
if (iter == m_object_creator.end())
return 0;

return ((*iter).second)(a0);
}

ConstIterator GetBegin() const
{
return m_object_creator.begin();
}

Iterator GetBegin()
{
return m_object_creator.begin();
}

ConstIterator GetEnd() const
{
return m_object_creator.end();
}

Iterator GetEnd()
{
return m_object_creator.end();
}

protected:
std::map<UniqueIdType, CreateObjectFunc> m_object_creator;
};

///////////////////////////////////////////////////////////////////////////////

template<typename BaseClassType, typename A0, typename A1, typename ClassType> BaseClassType CreateObject(A0 a0, A1 a1)
{
return new ClassType(a0, a1);
}

template<typename BaseClassType, typename A0, typename A1, typename UniqueIdType>
class ObjectFactory<BaseClassType(A0, A1), UniqueIdType>
{

private:
typedef BaseClassType(*CreateObjectFunc)(A0 a0, A1 a1);

public:
typedef typename std::map<UniqueIdType, CreateObjectFunc>::const_iterator ConstIterator;
typedef typename std::map<UniqueIdType, CreateObjectFunc>::iterator Iterator;

template<typename ClassType>
bool Register(UniqueIdType unique_id)
{
if (m_object_creator.find(unique_id) != m_object_creator.end())
return false;

m_object_creator[unique_id] = &CreateObject<BaseClassType, A0, A1, ClassType>;

return true;
}

bool Unregister(UniqueIdType unique_id)
{
return (m_object_creator.erase(unique_id) == 1);
}

BaseClassType Create(UniqueIdType unique_id, A0 a0, A1 a1)
{
Iterator iter = m_object_creator.find(unique_id);

if (iter == m_object_creator.end())
return 0;

return ((*iter).second)(a0, a1);
}

ConstIterator GetBegin() const
{
return m_object_creator.begin();
}

Iterator GetBegin()
{
return m_object_creator.begin();
}

ConstIterator GetEnd() const
{
return m_object_creator.end();
}

Iterator GetEnd()
{
return m_object_creator.end();
}

protected:
std::map<UniqueIdType, CreateObjectFunc> m_object_creator;
};

...









Also, should I rebuild my engine to fit VC++7.1 standards?

Quote:

Important Note: This code has been tested on Visual C++ 7.1. However, because the final implementation of the object factory uses partial template specialization some non-compliant compilers, such as Visual C++ 6.0, will not be able to compile this code.

Because of this, the source attached to this article also contains a special version of the object factory written specifically for Visual C++ 6.0. To get around the lack of partial template specialization support on Visual C++ 6.0 we must have a separate object factory class for each constructor parameter. Also, because of Visual C++ 6.0's lack of 'explicit template argument specification for member functions' support we must use a hack on the Register function. Below is an example of how to use the object factory in Visual C++ 6.0:



Also, I sent him a reply and asked

Shamino
Quote:

Holy wow, nice macro....

Basically with this lil snippet

MACRO_REPEAT(16, OBJECT_FACTORY)

So, for that final super template (the one in your final code) it requires a whole 15 parameters (which would also require template classes to make)? Or are you just only using a few of these 15?

Are you like, creating support for 15 parameters? Or do you actually need this many?


And Robert said
Quote:

Correct, calling that macro creates 16 different versions of the class, so I could support from 0 to 15 parameters. If you knew that you'd ALWAYS use the ObjectFactory passing EXACTLY one constructor parameter, then you could just copy that second class instance in the text file I sent you, then the following would work fine:
ObjectFactory<Command *(int), std::string> CommandFactory;

but this would not:
ObjectFactory<Command *(int, int), std::string> CommandFactory;

Since most people would never use more than 15 parameters I decided to stick with that number, so you could create instances that pass anywhere from 0 - 15 parameters. You could use 8 if you knew you'd never pass more than 8 constructor parameters.

Rob Geiman


I sent him a final question

[quote]
Another question..

And finally, your code simply doesn't work on my VC++6.0 compiler (example2), should i rebuild my 3000 line game engine to fit into VC++7.1?

I understand that 3000 lines is not a lot, but me as an amature programmer, this would be quite a daunting task.

If it is something I can fix I'll send you the errors I get when I try to compile.

--------------------Configuration: ObjectFactory - Win32 Debug--------------------
Compiling...
main.cpp
c:\documents and settings\jonathan\desktop\objectfactory\objectfactory.h(56) : error C2649: 'typename' : is not a ''
c:\documents and settings\jonathan\desktop\objectfactory\objectfactory.h(56) : error C2059: syntax error : '>'
c:\documents and settings\jonathan\desktop\objectfactory\objectfactory.h(57) : error C2014: preprocessor command must start as first nonwhite space
c:\documents and settings\jonathan\desktop\objectfactory\objectfactory.h(81) : error C2014: preprocessor command must start as first nonwhite space
c:\documents and settings\jonathan\desktop\objectfactory\objectfactory.h(150) : error C2992: 'ObjectFactory' : invalid or missing template parameter list
c:\documents and settings\jonathan\desktop\objectfactory\objectfactory.h(150) : see declaration of 'ObjectFactory'
c:\documents and settings\jonathan\desktop\objectfactory\example2.h(17) : error C2143: syntax error : missing ';' before '<'
c:\documents and settings\jonathan\desktop\objectfactory\example2.h(17) : error C2143: syntax error : missing ';' before '<'
c:\documents and settings\jonathan\desktop\objectfactory\example2.h(18) : error C2146: syntax error : missing ';' before identifier 'command_factory'
c:\documents and settings\jonathan\desktop\objectfactory\example2.h(18) : error C2501: 'CommandFactory' : missing storage-class or type specifiers
c:\documents and settings\jonathan\desktop\objectfactory\example2.h(18) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
Creating browse info file...
BSCMAKE: error BK1506 : cannot open file '.\Debug\main.sbr': No such file or directory
Error executing bscmake.exe.
ObjectFactory.exe - 11 error(s), 0 warning(s)





[/quote]

His reply
Quote:

If I were you, I'd write all future program using VC++ 7.1. It's MUCH more C++ compliant than VC++ 6.0.

However, no reason to rewrite your current game engine. In the zip file from the tutorial there should be a VC++ 6.0 specific version of the object factory, which should compile just fine.

Rob Geiman


(I don't think he realizes that HIS VC++6 code is NOT compiling) Maybe I'm just bad at template syntax and can't see the issue..

EDIT: Lol, I challenged the programming Buddha and failed. I got errors due to overwriting the vc6 source with vc7 source and then back again to vc6 source, expecting it to work.

This is TRULY AMAZING, like, holy freakin wowazation. Its so amazing I had to make up a new word for it. Like.... Holy Grail of Object Oriented Design. And as the creator, that like, makes Robert Geiman... Like, the Jesus of OOP (or at least another high prophet or aposcle)

[Edited by - Shamino on December 16, 2005 5:28:27 PM]

Share this post


Link to post
Share on other sites

This topic is 4380 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this